Class: Rubocop::Cop::WhileUntilModifier
- Includes:
- FavorModifier
- Defined in:
- lib/rubocop/cop/favor_modifier.rb
Constant Summary collapse
- MSG =
'Favor modifier while/until usage when you have a single-line body.'
Instance Attribute Summary
Attributes inherited from Cop
#debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods included from FavorModifier
Methods inherited from Cop
#add_offence, cop_name, #has_report?, #ignore_node, 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
67 68 69 70 71 |
# File 'lib/rubocop/cop/favor_modifier.rb', line 67 def inspect(source, tokens, ast, comments) on_node([:while, :until], ast) do |node| add_offence(:convention, node.loc.line, MSG) if check(node) end end |