Class: Rubocop::Cop::UnlessElse
- Defined in:
- lib/rubocop/cop/unless_else.rb
Constant Summary collapse
- ERROR_MESSAGE =
'Never use unless with else. Rewrite these with the ' + 'positive case first.'
Instance Attribute Summary
Attributes inherited from Cop
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, #has_report?, inherited, #initialize
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(file, source, tokens, sexp) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/rubocop/cop/unless_else.rb', line 9 def inspect(file, source, tokens, sexp) each(:unless, sexp) do |unless_sexp| if unless_sexp.compact.find { |s| s[0] == :else } add_offence(:convention, all_positions(unless_sexp).first.lineno, ERROR_MESSAGE) end end end |