Sha256: 8e31efee319b32b3a63fadce2c289121f00aa21fb4eb65d85bb01a011e1aca40

Contents?: true

Size: 913 Bytes

Versions: 7

Compression:

Stored size: 913 Bytes

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module RuboCop
  module Cop
    module Security
      module Object
        # This cop checks for the use of `Object#method`.
        #
        # @example
        #
        #   # bad
        #   Object.method
        #
        #   # good
        #   Object.cs__method
        class Method < Cop
          MSG = 'The use of `Object#method` is a compatibility risk.'

          def eligible_node? node
            node.method?(:method)
          end

          def on_send node
            return false unless eligible_node?(node)

            add_offense(node, location: :selector)
          end

          def autocorrect node
            ->(corrector) { corrector.replace(node.loc.selector, 'cs__method') }
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
contrast-agent-3.10.2 resources/rubocops/object/respond_to_cop.rb
contrast-agent-3.10.1 resources/rubocops/object/respond_to_cop.rb
contrast-agent-3.10.0 resources/rubocops/object/respond_to_cop.rb
contrast-agent-3.9.1 resources/rubocops/object/respond_to_cop.rb
contrast-agent-3.9.0 resources/rubocops/object/respond_to_cop.rb
contrast-agent-3.8.5 resources/rubocops/object/respond_to_cop.rb
contrast-agent-3.8.4 resources/rubocops/object/respond_to_cop.rb