From 6d72c730962dd0aee9d80daab6e9269a2bbdceee Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Mon, 8 Apr 2024 15:27:20 +0900 Subject: [PATCH] Run tests with Prism 0.25 Run tests with Prism 0.25 and fixes the following build errors: ```console $ bundle exec rake (snip) ==> Failures 1) RuboCop::Cop::Performance::RedundantMatch behaves like require no parentheses registers an offense and corrects when argument is `yield` Failure/Error: expect_offense(<<~RUBY, arg: arg) something if /regex/.match(%{arg}) ^^^^^^^^^^^^^^^{arg}^ Use `=~` in places where the `MatchData` returned by `#match` will not be used. RUBY RuntimeError: Error parsing example code: (string):1:28: error: Invalid yield (string):1: something if /regex/.match(yield) (string):1: ^~~~~ Shared Example Group: "require no parentheses" called from ./spec/rubocop/cop/performance/redundant_match_spec.rb:162 # ./spec/rubocop/cop/performance/redundant_match_spec.rb:148:in `block (3 levels) in ' 2) RuboCop::Cop::Performance::RedundantMatch behaves like require parentheses registers an offense and corrects when argument is `yield a` Failure/Error: expect_offense(<<~RUBY, arg: arg) something if /regex/.match(%{arg}) ^^^^^^^^^^^^^^^{arg}^ Use `=~` in places where the `MatchData` returned by `#match` will not be used. RUBY RuntimeError: Error parsing example code: (string):1:28: error: Invalid yield (string):1: something if /regex/.match(yield a) (string):1: ^~~~~~~ Shared Example Group: "require parentheses" called from ./spec/rubocop/cop/performance/redundant_match_spec.rb:142 # ./spec/rubocop/cop/performance/redundant_match_spec.rb:126:in `block (3 levels) in ' rake aborted! ``` --- spec/rubocop/cop/performance/redundant_match_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/rubocop/cop/performance/redundant_match_spec.rb b/spec/rubocop/cop/performance/redundant_match_spec.rb index 0d6a8767ea..faa4a1ea79 100644 --- a/spec/rubocop/cop/performance/redundant_match_spec.rb +++ b/spec/rubocop/cop/performance/redundant_match_spec.rb @@ -139,7 +139,11 @@ def method(str) it_behaves_like 'require parentheses', 'a || b' it_behaves_like 'require parentheses', 'a..b' it_behaves_like 'require parentheses', 'method a' - it_behaves_like 'require parentheses', 'yield a' + + context 'when Ruby <= 3.2', :ruby32, unsupported_on: :prism do # rubocop:disable RSpec/RepeatedExampleGroupDescription + it_behaves_like 'require parentheses', 'yield a' + end + it_behaves_like 'require parentheses', 'super a' it_behaves_like 'require parentheses', 'a == b' @@ -159,7 +163,11 @@ def method(str) it_behaves_like 'require no parentheses', 'if a then b else c end' it_behaves_like 'require no parentheses', 'method(a)' it_behaves_like 'require no parentheses', 'method' - it_behaves_like 'require no parentheses', 'yield' + + context 'when Ruby <= 3.2', :ruby32, unsupported_on: :prism do # rubocop:disable RSpec/RepeatedExampleGroupDescription + it_behaves_like 'require no parentheses', 'yield' + end + it_behaves_like 'require no parentheses', 'super' it_behaves_like 'require no parentheses', 'a.==(b)'