Ruby

Ruby

Made by DeepSource

each_with_object is called with an immutable argument RB-LI1014

Bug risk
Major

Since the argument is the object that the given block shall make calls on to build something based on the enumerable that eachwithobject iterates over, an immutable argument makes no sense. It's definitely a bug.

Bad practice

sum = numbers.each_with_object(0) { |e, a| a += e }

Recommended

num = 0
sum = numbers.each_with_object(num) { |e, a| a += e }