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
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(source, tokens, ast, comments) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/rubocop/cop/favor_modifier.rb', line 82 def inspect(source, tokens, ast, comments) on_node([:while, :until], ast) do |node| # discard modifier while/until next unless node.loc.end add_offence(:convention, node.loc.line, MSG) if check(node) end end |