Class: Shirobai::Cop::RSpec::SortMetadata
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::RSpec::SortMetadata
show all
- Extended by:
- RuboCop::Cop::AutoCorrector
- Includes:
- RuboCop::Cop::RangeHelp, RuboCop::RSpec::Language, MetadataSupport
- Defined in:
- lib/shirobai/cop/rspec/sort_metadata.rb
Overview
Drop-in Rust reimplementation of RSpec/SortMetadata
(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. The comparator (key.source.downcase /
value.to_s.downcase), the ambiguous-trailing guard, and the
map(&:source).join(", ") replacement all match byte for byte.
Constant Summary
collapse
- MSG =
"Sort metadata alphabetically."
Class Method Summary
collapse
Instance Method Summary
collapse
#metadata_in_block, #on_new_investigation, #rspec_configure, #rspec_metadata
Class Method Details
.badge ⇒ Object
24
|
# File 'lib/shirobai/cop/rspec/sort_metadata.rb', line 24
def self.badge = RuboCop::Cop::Badge.parse(cop_name)
|
.bundle_args(_config) ⇒ Object
26
27
28
|
# File 'lib/shirobai/cop/rspec/sort_metadata.rb', line 26
def self.bundle_args(_config)
[]
end
|
.cop_name ⇒ Object
23
|
# File 'lib/shirobai/cop/rspec/sort_metadata.rb', line 23
def self.cop_name = "RSpec/SortMetadata"
|
Instance Method Details
33
34
35
|
# File 'lib/shirobai/cop/rspec/sort_metadata.rb', line 33
def_node_matcher :match_ambiguous_trailing_metadata?, <<~PATTERN
(send _ _ _ ... !{hash sym any_str})
PATTERN
|
30
|
# File 'lib/shirobai/cop/rspec/sort_metadata.rb', line 30
def metadata_slot = :rspec_sort_metadata
|
--- stock's private methods, copied verbatim (rubocop-rspec 3.10.2) ---
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/shirobai/cop/rspec/sort_metadata.rb', line 39
def on_metadata(args, hash)
pairs = hash&.pairs || []
symbols = trailing_symbols(args)
return if sorted?(symbols, pairs)
crime_scene = crime_scene(symbols, pairs)
add_offense(crime_scene) do |corrector|
corrector.replace(crime_scene, replacement(symbols, pairs))
end
end
|