Skip to content

Commit b8a0eb1

Browse files
authored
Merge pull request #2005 from rubocop/fix-empty-metadata-for-kwargs-splat
Fix EmptyMetadata for splat kwargs
2 parents 274c7d9 + 4832625 commit b8a0eb1

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Master (Unreleased)
44

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

78
## 3.2.0 (2024-10-26)
89

lib/rubocop/cop/rspec/empty_metadata.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class EmptyMetadata < Base
2121

2222
def on_metadata(_symbols, hash)
2323
return unless hash&.pairs&.empty?
24+
return if hash.children.any?(&:kwsplat_type?)
2425

2526
add_offense(hash) do |corrector|
2627
remove_empty_metadata(corrector, hash)

spec/rubocop/cop/rspec/empty_metadata_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@
3333
RUBY
3434
end
3535
end
36+
37+
it 'registers no offense for splat kwargs metadata' do
38+
expect_no_offenses(<<~RUBY)
39+
describe 'Something', **{ a: b } do
40+
end
41+
RUBY
42+
end
3643
end

0 commit comments

Comments
 (0)