Sha256: d144c770a01bad46dd13406576d42443b73f3b652d3670d518b91f709553c71b

Contents?: true

Size: 836 Bytes

Versions: 3

Compression:

Stored size: 836 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks for the presence of superfluous parentheses around the
      # condition of if/while/until.
      class ParenthesesAroundCondition < Cop
        MSG = "Don't use parentheses around the condition of an " +
          'if/unless/while/until'

        def on_if(node)
          process_control_op(node)

          super
        end

        def on_while(node)
          process_control_op(node)

          super
        end

        def on_until(node)
          process_control_op(node)

          super
        end

        private

        def process_control_op(node)
          cond, _body = *node

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 lib/rubocop/cop/style/parentheses_around_condition.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/style/parentheses_around_condition.rb
rubocop-0.9.0 lib/rubocop/cop/style/parentheses_around_condition.rb