module RuboCop::AST::MethodDispatchNode
def access_modifier?
-
(Boolean)
- whether the dispatched method is an access modifier
def access_modifier? bare_access_modifier? || non_bare_access_modifier? end
def arguments
-
(Array
- the arguments of the dispatched method)
def arguments node_parts[2..-1] end
def arithmetic_operation?
-
(Boolean)
- whether the dispatched method is an arithmetic
def arithmetic_operation? ARITHMETIC_OPERATORS.include?(method_name) end
def bare_access_modifier?
-
(Boolean)
- whether the dispatched method is a bare
def bare_access_modifier? macro? && bare_access_modifier_declaration? end
def binary_operation?
-
(Bookean)
- whether this method is a binary operation
def binary_operation? return false unless loc.selector operator_method? && loc.expression.begin_pos != loc.selector.begin_pos end
def block_literal?
-
(Boolean)
- whether the dispatched method has a block
def block_literal? parent&.block_type? && eql?(parent.send_node) end
def block_node
-
(BlockNode, nil)
- the `block` node associated with this method
def block_node parent if block_literal? end
def command?(name)
-
(Boolean)
- whether the method name matches the argument
Parameters:
-
name
(Symbol, String
) -- the method name to check for
def command?(name) !receiver && method?(name) end
def const_receiver?
-
(Boolean)
- whether the receiver of this method dispatch
def const_receiver? receiver&.const_type? end
def def_modifier?
-
(Boolean)
- whether the dispatched method is a `def` modifier
def def_modifier? send_type? && [self, *each_descendant(:send)].any?(&:adjacent_def_modifier?) end
def dot?
-
(Boolean)
- whether the method was called with a connecting dot
def dot? loc.respond_to?(:dot) && loc.dot && loc.dot.is?('.') end
def double_colon?
-
(Boolean)
- whether the method was called with a connecting dot
def double_colon? loc.respond_to?(:dot) && loc.dot && loc.dot.is?('::') end
def implicit_call?
-
(Boolean)
- whether the method is the implicit form of `#call`
def implicit_call? method?(:call) && !loc.selector end
def lambda?
-
(Boolean)
- whether this method is a lambda
def lambda? block_literal? && command?(:lambda) end
def lambda_literal?
-
(Boolean)
- whether this method is a lambda literal
def lambda_literal? block_literal? && loc.expression && loc.expression.source == '->' end
def macro?
-
(Boolean)
- whether the dispatched method is a macro method
Other tags:
- Note: - This does not include DSLs that use nested blocks, like RSpec
def macro? !receiver && macro_scope? end
def macro_kwbegin_wrapper?(parent)
-
(Boolean)
- true if the parent is a kwbegin in a macro scope
Parameters:
-
parent
(Node
) -- parent of the node being checked
def macro_kwbegin_wrapper?(parent) parent.kwbegin_type? && macro_scope?(parent) end
def method_name
-
(Symbol)
- the name of the dispatched method
def method_name node_parts[1] end
def non_bare_access_modifier?
-
(Boolean)
- whether the dispatched method is a non-bare
def non_bare_access_modifier? macro? && non_bare_access_modifier_declaration? end
def receiver
-
(Node, nil)
- the receiver of the dispatched method or `nil`
def receiver node_parts[0] end
def root_node?(node)
-
(Boolean)
- if the parent is nil
Parameters:
-
node
(Node
) --
def root_node?(node) node.parent.nil? end
def safe_navigation?
-
(Boolean)
- whether the method was called with a connecting dot
def safe_navigation? loc.respond_to?(:dot) && loc.dot && loc.dot.is?('&.') end
def self_receiver?
-
(Boolean)
- whether the receiver of this method dispatch is `self`
def self_receiver? receiver&.self_type? end
def setter_method?
-
(Boolean)
- whether the dispatched method is a setter
def setter_method? loc.respond_to?(:operator) && loc.operator end
def special_modifier?
-
(Boolean)
- whether the dispatched method is a bare
def special_modifier? bare_access_modifier? && SPECIAL_MODIFIERS.include?(source) end
def unary_operation?
-
(Boolean)
- whether this method is a unary operation
def unary_operation? return false unless loc.selector operator_method? && loc.expression.begin_pos == loc.selector.begin_pos end