Parent

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::SignalException

This cop checks for uses of `fail` and `raise`.

Constants

FAIL_MSG
RAISE_MSG

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/style/signal_exception.rb, line 35
def autocorrect(node)
  @corrections << lambda do |corrector|
    name =
      case style
      when :semantic then command?(:raise, node) ? 'fail' : 'raise'
      when :only_raise then 'raise'
      when :only_fail then 'fail'
      end

    corrector.replace(node.loc.selector, name)
  end
end
on_rescue(node) click to toggle source
# File lib/rubocop/cop/style/signal_exception.rb, line 12
def on_rescue(node)
  return unless style == :semantic

  begin_node, *rescue_nodes, _else_node = *node
  check_for(:raise, begin_node)

  rescue_nodes.each do |rescue_node|
    check_for(:fail, rescue_node)
    allow(:raise, rescue_node)
  end
end
on_send(node) click to toggle source
# File lib/rubocop/cop/style/signal_exception.rb, line 24
def on_send(node)
  case style
  when :semantic
    check_for(:raise, node) unless ignored_node?(node)
  when :only_raise
    check_for(:raise, node)
  when :only_fail
    check_for(:fail, node)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.