Skip to content
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

Improve Performance/RedundantSortBlock cop #383

Open
ydakuka opened this issue Nov 17, 2023 · 0 comments
Open

Improve Performance/RedundantSortBlock cop #383

ydakuka opened this issue Nov 17, 2023 · 0 comments

Comments

@ydakuka
Copy link
Contributor

ydakuka commented Nov 17, 2023

https://docs.rubocop.org/rubocop-performance/cops_performance.html#performanceredundantsortblock

Implemented

# bad
array.sort { |x, y| x <=> y }
# good
array.sort

Not implemented

# bad
array.sort! { |x, y| x <=> y }
# good
array.sort!

# bad
array.min { |x, y| x <=> y }
# good
array.min

# bad
array.min { |x, y| y <=> x }
# good
array.max

# bad
array.max { |x, y| x <=> y }
# good
array.max

# bad
array.max { |x, y| y <=> x }
# good
array.min

# bad
array.minmax { |x, y| x <=> y }
# good
array.minmax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant