diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b640f048..5eb3d6854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/rubocop/cop/rspec/empty_metadata.rb b/lib/rubocop/cop/rspec/empty_metadata.rb index 7cb3e9483..390059c31 100644 --- a/lib/rubocop/cop/rspec/empty_metadata.rb +++ b/lib/rubocop/cop/rspec/empty_metadata.rb @@ -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) diff --git a/spec/rubocop/cop/rspec/empty_metadata_spec.rb b/spec/rubocop/cop/rspec/empty_metadata_spec.rb index 25ee913fc..8a36b6f85 100644 --- a/spec/rubocop/cop/rspec/empty_metadata_spec.rb +++ b/spec/rubocop/cop/rspec/empty_metadata_spec.rb @@ -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