You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.sum
and
paid_bills.sum
Steps to reproduce the problem
Let rubocop-performance autocorrect the examples given above
When autocorrecting, the new Performance/Sum cop should take the initial value provided to
inject
orreduce
and pass that as the first argument tosum
, even when it is not a number literal.This is corrected correctly:
But this is not:
Expected behavior
The code
should be corrected to
Also, more complex code like the following real-world example:
should be corrected to
Actual behavior
The two examples given above are corrected to
and
Steps to reproduce the problem
Let
rubocop-performance
autocorrect the examples given aboveRuboCop version
rubocop-performance
is at version 1.8.0.The text was updated successfully, but these errors were encountered: