Sha256: 37ce9b36f9a20892b06b1fe0029af928269c8f8865cdbc5ebe77308d372e62c6

Contents?: true

Size: 710 Bytes

Versions: 6765

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for the use of the send method.
      #
      # @example
      #   # bad
      #   Foo.send(:bar)
      #   quuz.send(:fred)
      #
      #   # good
      #   Foo.__send__(:bar)
      #   quuz.public_send(:fred)
      class Send < Cop
        MSG = 'Prefer `Object#__send__` or `Object#public_send` to ' \
              '`send`.'.freeze

        def_node_matcher :sending?, '({send csend} _ :send ...)'

        def on_send(node)
          return unless sending?(node) && node.arguments?

          add_offense(node, location: :selector)
        end
        alias on_csend on_send
      end
    end
  end
end

Version data entries

6,765 entries across 6,761 versions & 23 rubygems

Version Path
rubocop-0.67.1 lib/rubocop/cop/style/send.rb
rubocop-0.67.0 lib/rubocop/cop/style/send.rb
rubocop-0.66.0 lib/rubocop/cop/style/send.rb
rubocop-0.65.0 lib/rubocop/cop/style/send.rb
rubocop-0.64.0 lib/rubocop/cop/style/send.rb