Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EmptyMetadata for splat kwargs #2005

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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
Loading