Class: Rubocop::Cop::Style::OneLineConditional
- Includes:
- IfThenElse
- Defined in:
- lib/rubocop/cop/style/one_line_conditional.rb
Overview
Checks for uses of if/then/else/end on a single line.
Instance Attribute Summary
Attributes inherited from Cop
#autocorrect, #corrections, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods included from IfThenElse
Methods inherited from Cop
#add_offence, all, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#error_message ⇒ Object
14 15 16 |
# File 'lib/rubocop/cop/style/one_line_conditional.rb', line 14 def 'Favor the ternary operator (?:) over if/then/else/end constructs.' end |
#offending_line(node) ⇒ Object
10 11 12 |
# File 'lib/rubocop/cop/style/one_line_conditional.rb', line 10 def offending_line(node) node.loc.expression.line unless node.loc.expression.source =~ /\n/ end |