Class: RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector

Inherits:
Object
  • Object
show all
Extended by:
NodePattern::Macros
Defined in:
lib/rubocop/cop/performance/redundant_merge.rb

Overview

A utility class for checking the use of values within an `each_with_object` call.

Instance Method Summary collapse

Methods included from NodePattern::Macros

def_node_matcher, def_node_search, node_search, node_search_all, node_search_body, node_search_first

Constructor Details

#initialize(node, receiver) ⇒ EachWithObjectInspector



143
144
145
146
# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 143

def initialize(node, receiver)
  @node = node
  @receiver = unwind(receiver)
end

Instance Method Details

#value_used?Boolean



148
149
150
151
152
# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 148

def value_used?
  return false unless eligible_receiver? && second_argument

  receiver.loc.name.source == second_argument.loc.name.source
end