-
-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When autocorrecting, the new Performance/Sum cop should take the initial value provided to inject or reduce and pass that as the first argument to sum, even when it is not a number literal.
This is corrected correctly:
foo.inject(23, :+)But this is not:
foo.inject(bar, :+)Expected behavior
The code
foo.inject(bar, :+)should be corrected to
foo.sum(bar)Also, more complex code like the following real-world example:
paid_bills.reduce(AmountWithVAT.new, :+)should be corrected to
paid_bills.sum(AmountWithVAT.new)Actual behavior
The two examples given above are corrected to
foo.sumand
paid_bills.sumSteps to reproduce the problem
Let rubocop-performance autocorrect the examples given above
RuboCop version
0.90.0 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.7.1 x86_64-linux)
rubocop-performance is at version 1.8.0.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working