Class: Shirobai::Cop::RSpec::EmptyMetadata

Inherits:
RuboCop::Cop::Base
  • Object
show all
Extended by:
RuboCop::Cop::AutoCorrector
Includes:
RuboCop::Cop::RangeHelp, RuboCop::RSpec::Language, MetadataSupport
Defined in:
lib/shirobai/cop/rspec/empty_metadata.rb

Overview

Drop-in Rust reimplementation of RSpec/EmptyMetadata (rubocop-rspec 3.10.2).

Rust supplies the shared metadata-anchor block ranges; this wrapper relocates each parser block node and runs stock's on_metadata plus autocorrect VERBATIM (empty-hash detection, kwsplat guard, and the comma/space-aware removal all match byte for byte).

Constant Summary collapse

MSG =
"Avoid empty metadata hash."

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MetadataSupport

#metadata_in_block, #on_new_investigation, #rspec_configure, #rspec_metadata

Class Method Details

.badgeObject



23
# File 'lib/shirobai/cop/rspec/empty_metadata.rb', line 23

def self.badge = RuboCop::Cop::Badge.parse(cop_name)

.bundle_args(_config) ⇒ Object



25
26
27
# File 'lib/shirobai/cop/rspec/empty_metadata.rb', line 25

def self.bundle_args(_config)
  []
end

.cop_nameObject



22
# File 'lib/shirobai/cop/rspec/empty_metadata.rb', line 22

def self.cop_name = "RSpec/EmptyMetadata"

Instance Method Details

#metadata_slotObject



29
# File 'lib/shirobai/cop/rspec/empty_metadata.rb', line 29

def  = :rspec_empty_metadata

#on_metadata(_symbols, hash) ⇒ Object

--- stock's private methods, copied verbatim (rubocop-rspec 3.10.2) ---



33
34
35
36
37
38
39
40
# File 'lib/shirobai/cop/rspec/empty_metadata.rb', line 33

def (_symbols, hash)
  return unless hash&.pairs&.empty?
  return if hash.children.any?(&:kwsplat_type?)

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