class RuboCop::Cop::RSpec::EmptyMetadata
Avoid empty metadata hash.
@example EnforcedStyle: symbol (default)
# bad describe 'Something', {} # good describe 'Something'
Constants
- MSG
Public Instance Methods
Source
# File lib/rubocop/cop/rspec/empty_metadata.rb, line 22 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) end end
Private Instance Methods
Source
# File lib/rubocop/cop/rspec/empty_metadata.rb, line 33 def remove_empty_metadata(corrector, node) corrector.remove( range_with_surrounding_comma( range_with_surrounding_space( node.source_range, side: :left ), :left ) ) end