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/RedundantParentheses #6995

Merged

Commits on Apr 29, 2019

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

    This PR fixes an incorrect auto-correct for `Style/RedundantParentheses`
    when enclosed in parentheses at `while-post` or `until-post`.
    
    The following is a reproduction step.
    
    ```console
    % rubocop example1.rb --only Style/RedundantParentheses -a
    Inspecting 1 file
    E
    
    Offenses:
    
    example1.rb:3:5: E: Lint/Syntax: unexpected token tIDENTIFIER
    (Using Ruby 2.2 parser; configure using TargetRubyVersion parameter,
    under AllCops)
    end whilefoo
        ^^^^^^^^
    example1.rb:3:10: C: [Corrected] Style/RedundantParentheses:
    Don't use parentheses around a method call.
    end while(foo)
        ^^^^^
    
    1 file inspected, 2 offenses detected, 1 offense corrected
    ```
    
    This is a broken `while`.
    
    ```diff
    % git diff
    diff --git a/example1.rb b/example1.rb
    index cf5523f..5f47ae4 100644
    --- a/example1.rb
    +++ b/example1.rb
    @@ -1,3 +1,3 @@
     begin
       do_something
    -end while(foo)
    +end whilefoo
    ```
    
    This will not be warned when `while` ... `end`.
    
    ```consle
    % cat example2.rb
    while(foo)
      do_something
    end
    
    % rubocop example2.rb --only Style/RedundantParentheses
    Inspecting 1 file
    .
    
    1 file inspected, no offenses detected
    ```
    
    So this PR changes to the same behavior.
    koic committed Apr 29, 2019
    Copy the full SHA
    804a646 View commit details
    Browse the repository at this point in the history