Module: RuboCop::Cop::OnNormalIfUnless

Includes:
IfNode
Included in:
Style::IfWithSemicolon, Style::MultilineIfThen, Style::OneLineConditional
Defined in:
lib/rubocop/cop/mixin/on_normal_if_unless.rb

Overview

Common functionality for cops checking if and unless statements.

Instance Method Summary collapse

Methods included from IfNode

#elsif?, #if_else?, #modifier_if?, #ternary_op?

Instance Method Details

#invoke_hook_for_normal_if_unless(node) ⇒ Object


17
18
19
20
21
# File 'lib/rubocop/cop/mixin/on_normal_if_unless.rb', line 17

def invoke_hook_for_normal_if_unless(node)
  # We won't check modifier or ternary conditionals.
  return if modifier_if?(node) || ternary_op?(node)
  on_normal_if_unless(node)
end

#on_if(node) ⇒ Object


9
10
11
# File 'lib/rubocop/cop/mixin/on_normal_if_unless.rb', line 9

def on_if(node)
  invoke_hook_for_normal_if_unless(node)
end

#on_unless(node) ⇒ Object


13
14
15
# File 'lib/rubocop/cop/mixin/on_normal_if_unless.rb', line 13

def on_unless(node)
  invoke_hook_for_normal_if_unless(node)
end