Class: RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
NodePattern::Macros
|
|
Inherits: | Object |
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.
Class Method Summary
- .new(node, receiver) ⇒ EachWithObjectInspector constructor
Instance Attribute Summary
- #value_used? ⇒ Boolean readonly
- #eligible_receiver? ⇒ Boolean readonly private
- #node readonly private
- #receiver readonly private
Instance Method Summary
- #second_argument private
- #unwind(receiver) private
Constructor Details
.new(node, receiver) ⇒ EachWithObjectInspector
Instance Attribute Details
#eligible_receiver? ⇒ Boolean
(readonly, private)
[ GitHub ]
#node (readonly, private)
[ GitHub ]# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 170
attr_reader :node, :receiver
#receiver (readonly, private)
[ GitHub ]# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 170
attr_reader :node, :receiver
#value_used? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 162
def value_used? return false unless eligible_receiver? && second_argument receiver.loc.name.source == second_argument.loc.name.source end
Instance Method Details
#second_argument (private)
[ GitHub ]# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 176
def second_argument parent = node.parent parent = parent.parent if parent.begin_type? @second_argument ||= each_with_object_node(parent) end