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 autocorrect for
Lint/AmbiguousBlockAssociation
This PR fixes the following incorrect autocorrect for `Lint/AmbiguousBlockAssociation` with `Style/MethodCallWithArgsParentheses`. ```ruby expect { foo }.not_to change { bar } ``` ## Before ```console $ bundle exec rubocop --only Lint/AmbiguousBlockAssociation,Style/MethodCallWithArgsParentheses -a Inspecting 1 file F Offenses: example.rb:1:1: W: [Corrected] Lint/AmbiguousBlockAssociation: Parenthesize the param change { bar } to make sure that the block will be associated with the change method call. expect { foo }.not_to change { bar } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ example.rb:1:1: C: [Corrected] Style/MethodCallWithArgsParentheses: Use parentheses for method calls with arguments. expect { foo }.not_to change { bar } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ example.rb:1:38: F: Lint/Syntax: unexpected token tRPAREN (Using Ruby 3.2 parser; configure using TargetRubyVersion parameter, under AllCops) expect { foo }.not_to(change { bar })) ^ 1 file inspected, 3 offenses detected, 2 offenses corrected ``` Syntax error with redundant closing parentheses. ```diff $ git diff . diff --git a/x/example.rb b/x/example.rb index 142ff55..6de7188 100644 --- a/x/example.rb +++ b/x/example.rb @@ -1 +1 @@ -expect { foo }.not_to change { bar } +expect { foo }.not_to(change { bar })) ``` ## After Valid syntax. ```diff $ git diff . diff --git a/x/example.rb b/x/example.rb index 142ff55..7808ed5 100644 --- a/x/example.rb +++ b/x/example.rb @@ -1 +1 @@ -expect { foo }.not_to change { bar } +expect { foo }.not_to(change { bar }) ```
- Loading branch information