Module: RuboCop::Cop::IfThenElse
- Defined in:
- lib/rubocop/cop/mixin/if_then_else.rb
Overview
Common functionality for cops checking if and unless statements.
Instance Method Summary collapse
Instance Method Details
#check(node) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rubocop/cop/mixin/if_then_else.rb', line 15 def check(node) # We won't check modifier or ternary conditionals. return unless node.loc.expression.source =~ /\A(if|unless)\b/ return unless offending_line(node) add_offense(node, :expression, (node)) end |
#on_if(node) ⇒ Object
7 8 9 |
# File 'lib/rubocop/cop/mixin/if_then_else.rb', line 7 def on_if(node) check(node) end |
#on_unless(node) ⇒ Object
11 12 13 |
# File 'lib/rubocop/cop/mixin/if_then_else.rb', line 11 def on_unless(node) check(node) end |