New issue
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
RedundantSort rule not working properly in case of max_by(&:size) #10061
Labels
Comments
8 tasks
koic
added a commit
to koic/rubocop
that referenced
this issue
Sep 1, 2021
Fixes rubocop#10061. This PR fixes a false positive for `Style/RedundantSort` when using `size` method in the block.
bbatsov
pushed a commit
that referenced
this issue
Sep 1, 2021
Fixes #10061. This PR fixes a false positive for `Style/RedundantSort` when using `size` method in the block.
Isn't this a problem in general when there are multiple values that translate to the same value? Even without I think this cop needs to be marked as unsafe. I opened #10122 for that. |
dvandersluis
added a commit
to dvandersluis/rubocop
that referenced
this issue
Sep 27, 2021
These changes added an exception for `size` but the same issue can occur regardless of what method is used, as long as it results in multiple values having the same resulting value. Instead, this cop is being made unsafe.
bbatsov
pushed a commit
that referenced
this issue
Sep 28, 2021
These changes added an exception for `size` but the same issue can occur regardless of what method is used, as long as it results in multiple values having the same resulting value. Instead, this cop is being made unsafe.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The goal:
return the last of most sized words in the string
A possible way to solve it:
This code raise
rubocop
offense:If we apply the suggested replacement, then we got a different result:
Expected behavior
No suggest replacement when the result going to change.
Actual behavior
Suggest replacement according to
Style/RedundantSort
rule with result changes.RuboCop version
The text was updated successfully, but these errors were encountered: