Class: Rubocop::Cop::MultilineIfThen

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

Instance Attribute Summary

Attributes inherited from Cop

#debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods included from IfThenElse

#check, #on_if, #on_unless

Methods inherited from Cop

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

Constructor Details

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

Instance Method Details

#error_messageObject



48
49
50
# File 'lib/rubocop/cop/if_then_else.rb', line 48

def error_message
  'Never use then for multi-line if/unless.'
end

#offending_line(node) ⇒ Object



42
43
44
45
46
# File 'lib/rubocop/cop/if_then_else.rb', line 42

def offending_line(node)
  if node.loc.expression.source =~ /\bthen\s*(#.*)?\s*$/
    node.loc.begin.line
  end
end