Class: Rubocop::Cop::FavorUnlessOverNegatedIf

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

Instance Attribute Summary

Attributes inherited from Cop

#correlations, #debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

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

Constructor Details

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

Instance Method Details

#error_messageObject



26
27
28
# File 'lib/rubocop/cop/favor_unless_over_negated_if.rb', line 26

def error_message
  'Favor unless (or control flow or) over if for negative conditions.'
end

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



30
31
32
# File 'lib/rubocop/cop/favor_unless_over_negated_if.rb', line 30

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