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

Fix an autocorrect for Style/RedundantSort with logical operator #10853

Merged

Commits on Aug 2, 2022

  1. Fix an autocorrect for Style/RedundantSort with logical operator

    This PR is fix an autocorrect for `Style/RedundantSort` with predicate operator
    
    If you have a code like the following:
    ```ruby
    [1, 2, 3]
      .sort_by { |x| x.length }
      .first || []
    ```
    
    After autocorrection it will look like this:
    ```ruby
    [1, 2, 3]
      .sort_by { |x| x.length }
      || []
    ```
    
    This is a syntax error.
    ```
    Error: : eval:3: syntax error, unexpected '|', expecting end-of-input
      || []
      ^
     (SyntaxError)
     ```
    ydah committed Aug 2, 2022
    Copy the full SHA
    4dd187a View commit details
    Browse the repository at this point in the history