Skip to content

Commit

Permalink
Fix EmptyMetadata for splat kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Dec 11, 2024
1 parent 274c7d9 commit c78cda4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Master (Unreleased)

- Deprecate `top_level_group?` method from `TopLevelGroup` mixin as all of its callers were intentionally removed from `Rubocop/RSpec`. ([@corsonknowles])
- Fix false positive for RSpec/EmptyMetadata for splat kwargs. [[@pirj]]

## 3.2.0 (2024-10-26)

Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/rspec/empty_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class EmptyMetadata < Base

def on_metadata(_symbols, hash)
return unless hash&.pairs&.empty?
return if hash.children.any?(&:kwsplat_type?)

add_offense(hash) do |corrector|
remove_empty_metadata(corrector, hash)
Expand Down
7 changes: 7 additions & 0 deletions spec/rubocop/cop/rspec/empty_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@
RUBY
end
end

it 'registers no offense for splat kwargs metadata' do
expect_no_offenses(<<~RUBY)
describe 'Something', **{ a: b } do
end
RUBY
end
end

0 comments on commit c78cda4

Please sign in to comment.