Sha256: 2fb3c336b82744102aa860728889c5caa03fbd7cf1a5d3ab2d7eab639d0b9091

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Lint
      # This cop checks for comparison of something with itself.
      #
      # @example
      #
      #  x.top >= x.top
      class UselessComparison < Cop
        MSG = 'Comparison of something with itself detected.'

        OPS = %w(== === != < > <= >= <=>)

        def on_send(node)
          op = node.loc.selector.source

          if OPS.include?(op)
            receiver, _method, args = *node

            warning(node, :selector) if receiver == args
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.13.0 lib/rubocop/cop/lint/useless_comparison.rb