Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information