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

Update Style/RedundantSort to be unsafe #10122

Merged
merged 3 commits into from Sep 28, 2021

Commits on Sep 27, 2021

  1. Revert changes from rubocop#10061.

    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.
    dvandersluis committed Sep 27, 2021
    Copy the full SHA
    b0cb09f View commit details
    Browse the repository at this point in the history
  2. Update Style/RedundantSort to be unsafe.

    In an array where there are multiple elements where `a <=> b` == 0, or where the transformation done by the block has the same result, there will be a different element returned between `sort.last` and `max` (or `sort_by.last` and `max_by`), because `sort.last` will take the last element but `max` will return the first element. As such, this is not a safe change, as the specific element returned will change.
    dvandersluis committed Sep 27, 2021
    Copy the full SHA
    71de8c2 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    ad5186f View commit details
    Browse the repository at this point in the history