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 incorrect auto-correct for Style/RedundantReturn #9631

Merged

Commits on Mar 22, 2021

  1. Fix an incorrect auto-correct for Style/RedundantReturn

    Fixes standardrb/standard#277.
    
    This PR fixes the following false positive for `Style/RedundantReturn`
    when using `return` with splat argument.
    
    ```console
    % cat example.rb
    class MyClass
      def something
        data = [1, 2, 3]
        return *data
      end
    end
    ```
    
    ## Before
    
    Auto-corrected to invalid code.
    
    ```console
    % rubocop --only Style/RedundantReturn -a
    (snip)
    
    % cat example.rb
    class MyClass
      def something
        data = [1, 2, 3]
        *data
      end
    end
    
    % ruby -c example.rb
    example.rb:4: syntax error, unexpected '\n', expecting '='
    ```
    
    ## After
    
    Auto-corrected to valid code.
    
    ```console
    % rubocop --only Style/RedundantReturn -a
    (snip)
    
    % cat example.rb
    class MyClass
      def something
        data = [1, 2, 3]
        data
      end
    end
    
    % ruby -c example.rb
    Syntax OK
    ```
    koic committed Mar 22, 2021
    Copy the full SHA
    978578a View commit details
    Browse the repository at this point in the history