Skip to content

Commit

Permalink
Ensure that the code for expect_correction is valid syntax
Browse files Browse the repository at this point in the history
Issues found with this:
* rubocop#13211
* rubocop#13215
* rubocop#13216
* rubocop#13219
* rubocop#13224
* rubocop#13225

I checked some repos in the rubocop org and they seem to not be affected by this change
  • Loading branch information
Earlopain authored and bbatsov committed Sep 13, 2024
1 parent 23b2e23 commit 6d708df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rubocop/rspec/expect_offense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def expect_correction(correction, loop: true, source: nil)
raise 'Expected correction but no corrections were made' if new_source == source

expect(new_source).to eq(correction)
expect(@processed_source).to be_valid_syntax, 'Expected correction to be valid syntax'
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity

Expand Down
2 changes: 2 additions & 0 deletions spec/rubocop/cop/style/operator_method_call_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
end

it "registers an offense when using `foo.#{operator_method}(bar)`" do
skip('https://github.com/rubocop/rubocop/issues/13225') if operator_method == :/

expect_offense(<<~RUBY, operator_method: operator_method)
foo.#{operator_method}(bar)
^ Redundant dot detected.
Expand Down

0 comments on commit 6d708df

Please sign in to comment.