Class: RuboCop::Cop::RSpec::SortMetadata
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp, Metadata
- Defined in:
- lib/rubocop/cop/rspec/sort_metadata.rb
Overview
Sort RSpec metadata alphabetically.
Constant Summary collapse
- MSG =
'Sort metadata alphabetically.'
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
26 27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/cop/rspec/sort_metadata.rb', line 26 def (symbols, hash) pairs = hash&.pairs || [] 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 |