Class: Shirobai::Cop::RSpec::MetadataStyle

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

Overview

Drop-in Rust reimplementation of RSpec/MetadataStyle (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 the full bidirectional autocorrect VERBATIM. EnforcedStyle is read here (ConfigurableEnforcedStyle) — Rust never needs it, since the anchor set is style-independent. The intricate insert/remove logic (siblings, braces, empty/non-empty hash, ambiguous trailing metadata) runs on the real parser AST, so it matches byte for byte.

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



25
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 25

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

.bundle_args(_config) ⇒ Object



27
28
29
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 27

def self.bundle_args(_config)
  []
end

.cop_nameObject



24
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 24

def self.cop_name = "RSpec/MetadataStyle"

Instance Method Details

#extract_metadata_hash(node) ⇒ Object



34
35
36
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 34

def_node_matcher :extract_metadata_hash, <<~PATTERN
  (send _ _ _ ... $hash)
PATTERN

#match_ambiguous_trailing_metadata?(node) ⇒ Object



44
45
46
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 44

def_node_matcher :match_ambiguous_trailing_metadata?, <<~PATTERN
  (send _ _ _ ... !{hash sym})
PATTERN

#match_boolean_metadata_pair?(node) ⇒ Object



39
40
41
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 39

def_node_matcher :match_boolean_metadata_pair?, <<~PATTERN
  (pair sym true)
PATTERN

#metadata_slotObject



31
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 31

def  = :rspec_metadata_style

#on_metadata(symbols, hash) ⇒ Object

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



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/shirobai/cop/rspec/metadata_style.rb', line 50

def (symbols, hash)
  symbols.each do |symbol|
    (symbol) if symbol.sym_type?
  end

  return unless hash

  hash.pairs.each do |pair|
    (pair)
  end
end