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/MethodCallWithArgsParentheses
This PR fixes the following incorrect auto-correct for `Style/MethodCallWithArgsParentheses` with `Style/RescueModifier`. ```console % cat example.rb do_something arg rescue nil % bundle exec rubocop -a --only Style/MethodCallWithArgsParentheses,Style/RescueModifier (snip) Inspecting 1 file C Offenses: example.rb:1:1: C: [Corrected] Style/MethodCallWithArgsParentheses: Use parentheses for method calls with arguments. do_something arg rescue nil ^^^^^^^^^^^^^^^^ example.rb:1:1: C: [Corrected] Style/RescueModifier: Avoid using rescue in its modifier form. do_something arg rescue nil ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 2 offenses detected, 2 offenses corrected ``` ## Before Auto-corrected to invalid syntax. ```ruby % cat example.rb begin do_something(arg rescue nil end) % ruby -c example.rb example.rb:3: syntax error, unexpected `rescue', expecting ')' rescue example.rb:5: syntax error, unexpected ')', expecting end-of-input ``` ## After Auto-corrected to valid syntax. ```ruby % cat example.rb begin do_something(arg) rescue nil end ```
- Loading branch information
Showing
4 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog/fix_incorrect_autocorrect_for_style_method_call_with_args_parentheses.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#9715](https://github.com/rubocop/rubocop/pull/9715): Fix an incorrect auto-correct for `EnforcedStyle: require_parentheses` of `Style/MethodCallWithArgsParentheses` with `Style/RescueModifier`. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters