Sha256: 65fc4336b0f9794cce05127d34bc5af12b274efa1ac4d115e4365e5098c7b44a

Contents?: true

Size: 492 Bytes

Versions: 1

Compression:

Stored size: 492 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class AndOr < Cop
      MSG = 'Use %s instead of %s.'

      OPS = { 'and' => '&&', 'or' => '||' }

      def on_and(node)
        op = node.loc.operator.source
        op_type = node.type.to_s

        if op == op_type
          add_offence(:convention,
                      node.loc.operator.line,
                      sprintf(MSG, OPS[op], op))
        end

        super
      end

      alias_method :on_or, :on_and
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.8.0 lib/rubocop/cop/and_or.rb