We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance/Sum
Right now, Performance/Sum works well for numeric values, but it does not recognize method calls:
[1, 2, 3].inject(0) { |sum, e| sum + e } # before [1, 2, 3].sum # after [1, 2, 3].inject(0) { |sum, e| sum + e.to_i } # no suggestion
No-op calls of to_i are here just to paint the picture. 🙂
to_i
It would be nice if RuboCop could recognize and simplify expressions as follows:
[1, 2, 3].inject(0) { |sum, e| sum + e.to_i } # before [1, 2, 3].sum(&:to_i) # after
I have checked RuboCop Rails and enabled ActiveSupportExtensionsEnabled, but this case does not seem to be supported by them.
ActiveSupportExtensionsEnabled
It might even be a safe operation. I am not aware of any downsides to it.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is your feature request related to a problem? Please describe.
Right now,
Performance/Sum
works well for numeric values, but it does not recognize method calls:No-op calls of
to_i
are here just to paint the picture. 🙂Describe the solution you'd like
It would be nice if RuboCop could recognize and simplify expressions as follows:
Describe alternatives you've considered
I have checked RuboCop Rails and enabled
ActiveSupportExtensionsEnabled
, but this case does not seem to be supported by them.Additional context
It might even be a safe operation. I am not aware of any downsides to it.
The text was updated successfully, but these errors were encountered: