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
Lint/AmbiguousOperator
This PR fixes the following incorrect auto-correct for `Style/MethodCallWithArgsParentheses` with `Lint/AmbiguousOperator`. ```console % cat example.rb def foo(&block) do_something &block end % rubocop --only Style/MethodCallWithArgsParentheses,Lint/AmbiguousOperator -a Inspecting 4 files ..WC Offenses: example.rb:2:3: C: [Corrected] Style/MethodCallWithArgsParentheses: Use parentheses for method calls with arguments. do_something &block ^^^^^^^^^^^^^^^^^^^ example.rb:2:16: W: [Corrected] Lint/AmbiguousOperator: Ambiguous block operator. Parenthesize the method arguments if it's surely a block operator, or add a whitespace to the right of the & if it should be a binary AND. do_something &block ^ ripper/example.rb:6:5: C: [Corrected] Style/MethodCallWithArgsParentheses: Use parentheses for method calls with arguments. raise message ^^^^^^^^^^^^^ 4 files inspected, 3 offenses detected, 3 offenses corrected ``` ## Before Syntax error with redundant closing parentheses. ```console % cat example.rb def foo(&block) do_something(&block)) end % ruby -c example.rb example.rb:2: syntax error, unexpected ')', expecting end do_something(&block)) ``` ## After Valid syntax. ```console % cat example.rb def foo(&block) do_something(&block) end ```
- Loading branch information