Expected behavior
After enabling Performance/Sum, I expect that the following lines will all be autocorrected to use sum:
[1, 2, 3].inject(:+)
[1, 2, 3].reduce(10, :+)
[1, 2, 3].reduce { |acc, elem| acc + elem }
Actual behavior
It only autocorrects the second line:
[1, 2, 3].inject(:+)
[1, 2, 3].sum(10)
[1, 2, 3].reduce { |acc, elem| acc + elem }
Steps to reproduce the problem
- Create a test file with those lines.
- Run
rubocop -A
OR
You can replicate this bug by pulling down this project, doing a bundle install, and running rubocop -A
RuboCop version
rubocop -V
0.91.0 (using Parser 2.7.1.4, rubocop-ast 0.4.2, running on ruby 2.7.0 x86_64-darwin19)