Class: RuboCop::Cop::RSpec::EmptyMetadata

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
RangeHelp, Metadata
Defined in:
lib/rubocop/cop/rspec/empty_metadata.rb

Overview

Avoid empty metadata hash.

Examples:

EnforcedStyle: symbol (default)

# bad
describe 'Something', {}

# good
describe 'Something'

Constant Summary collapse

MSG =
'Avoid empty metadata hash.'

Instance Method Summary collapse

Methods included from Metadata

#metadata_in_block, #on_block, #rspec_configure, #rspec_metadata

Methods included from RSpec::Language

#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?

Methods inherited from Base

inherited, #on_new_investigation

Instance Method Details

#on_metadata(_symbols, hash) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rubocop/cop/rspec/empty_metadata.rb', line 22

def (_symbols, hash)
  return unless hash&.pairs&.empty?

  add_offense(hash) do |corrector|
    (corrector, hash)
  end
end