class Rubocop::Cop::Style::ParenthesesAroundCondition

This cop checks for the presence of superfluous parentheses around the condition of if/while/until.

Constants

MSG

Public Instance Methods

on_if(node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/parentheses_around_condition.rb, line 12
def on_if(node)
  process_control_op(node)

  super
end
on_until(node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/parentheses_around_condition.rb, line 24
def on_until(node)
  process_control_op(node)

  super
end
on_while(node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/parentheses_around_condition.rb, line 18
def on_while(node)
  process_control_op(node)

  super
end

Private Instance Methods

process_control_op(node) click to toggle source
# File lib/rubocop/cop/style/parentheses_around_condition.rb, line 32
def process_control_op(node)
  cond, _body = *node

  if cond.type == :begin
    add_offence(:convention, cond.loc.expression, MSG)
  end
end