diff --git a/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb b/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb index 4e6ea7006c..d1ef3db49a 100644 --- a/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb +++ b/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb @@ -90,13 +90,9 @@ def use_block_argument_in_method_argument_of_operand?(block_argument, operand) return false unless operand.send_type? arguments = operand.arguments - operand_sources = arguments.map(&:source) - - arguments.each do |argument| - operand_sources += argument.each_descendant(:lvar).map(&:source) - end - - operand_sources.any?(block_argument.source) + arguments.inject(arguments.map(&:source)) do |operand_sources, argument| + operand_sources + argument.each_descendant(:lvar).map(&:source) + end.any?(block_argument.source) end def offense_range(node)