Class: Rubocop::Cop::IfUnlessModifier

Inherits:
Cop
  • Object
show all
Includes:
FavorModifier
Defined in:
lib/rubocop/cop/favor_modifier.rb

Instance Attribute Summary

Attributes inherited from Cop

#correlations, #offences

Instance Method Summary collapse

Methods included from FavorModifier

#check, #length

Methods inherited from Cop

#add_offence, #has_report?, inherited, #initialize

Constructor Details

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

Instance Method Details

#error_messageObject



60
61
62
63
# File 'lib/rubocop/cop/favor_modifier.rb', line 60

def error_message
  'Favor modifier if/unless usage when you have a single-line body. ' +
    'Another good alternative is the usage of control flow and/or.'
end

#inspect(file, source, tokens, sexp) ⇒ Object



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

def inspect(file, source, tokens, sexp)
  [:if, :unless].each { |kind| check(kind, tokens, sexp) }
end