Sha256: 4ba6c3736a8032badba87033134e9db3b8eb186a1ab01b98034a344e0705eb37

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module RuboCop
  module AST
    # A node extension for `send` nodes. This will be used in place of a plain
    # node when the builder constructs the AST, making its methods available
    # to all `send` nodes within RuboCop.
    class SendNode < Node
      include ParameterizedNode
      include MethodDispatchNode
      ARROW = '->'.freeze

      # Checks whether this is a negation method, i.e. `!` or keyword `not`.
      #
      # @return [Boolean] whether this method is a negation method
      def negation_method?
        keyword_bang? || keyword_not?
      end

      # Checks whether this is a lambda. Some versions of parser parses
      # non-literal lambdas as a method send.
      #
      # @return [Boolean] whether this method is a lambda
      def lambda?
        parent && parent.block_type? && method?(:lambda)
      end

      # Checks whether this is a stabby lambda. e.g. `-> () {}`
      #
      # @return [Boolean] whether this method is a staby lambda
      def stabby_lambda?
        selector = loc.selector
        selector && selector.source == ARROW
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubocop-0.58.2 lib/rubocop/ast/node/send_node.rb
rubocop-0.58.1 lib/rubocop/ast/node/send_node.rb
rubocop-0.58.0 lib/rubocop/ast/node/send_node.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubocop-0.57.2/lib/rubocop/ast/node/send_node.rb
rubocop-0.57.2 lib/rubocop/ast/node/send_node.rb
rubocop-0.57.1 lib/rubocop/ast/node/send_node.rb
rubocop-0.57.0 lib/rubocop/ast/node/send_node.rb
rubocop-0.56.0 lib/rubocop/ast/node/send_node.rb
rubocop-0.55.0 lib/rubocop/ast/node/send_node.rb
rubocop-0.54.0 lib/rubocop/ast/node/send_node.rb
rubocop-0.53.0 lib/rubocop/ast/node/send_node.rb