Class: Rubocop::Cop::WhileUntilModifier

Inherits:
Cop
  • Object
show all
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

#body_length, #check, #length

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



65
66
67
68
69
# File 'lib/rubocop/cop/favor_modifier.rb', line 65

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