Class: Rubocop::Cop::RescueModifier

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/rescue_modifier.rb

Constant Summary collapse

MSG =
'Avoid using rescue in its modifier form.'

Instance Attribute Summary

Attributes inherited from Cop

#debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, cop_name, #has_report?, inherited, #initialize, #name, #on_comment

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#inspect(source, tokens, ast, comments) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/rubocop/cop/rescue_modifier.rb', line 8

def inspect(source, tokens, ast, comments)
  on_node(:rescue, ast, :begin) do |s|
    add_offence(:convention,
                s.loc.line,
                MSG)
  end
end