Class: RuboCop::Cop::RSpec::MetadataStyle
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle, RangeHelp, Metadata
- Defined in:
- lib/rubocop/cop/rspec/metadata_style.rb
Overview
Use consistent metadata style.
This cop does not support autocorrection in the case of ‘EnforcedStyle: hash` where the trailing metadata type is ambiguous. (e.g. `describe ’Something’, :a, b`)
Instance Method Summary collapse
- #extract_metadata_hash(node) ⇒ Object
- #match_ambiguous_trailing_metadata?(node) ⇒ Object
- #match_boolean_metadata_pair?(node) ⇒ Object
- #on_metadata(symbols, hash) ⇒ Object
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
#extract_metadata_hash(node) ⇒ Object
33 34 35 |
# File 'lib/rubocop/cop/rspec/metadata_style.rb', line 33 def_node_matcher :extract_metadata_hash, <<~PATTERN (send _ _ _ ... $hash) PATTERN |
#match_ambiguous_trailing_metadata?(node) ⇒ Object
43 44 45 |
# File 'lib/rubocop/cop/rspec/metadata_style.rb', line 43 def_node_matcher :match_ambiguous_trailing_metadata?, <<~PATTERN (send _ _ _ ... !{hash sym}) PATTERN |
#match_boolean_metadata_pair?(node) ⇒ Object
38 39 40 |
# File 'lib/rubocop/cop/rspec/metadata_style.rb', line 38 def_node_matcher :match_boolean_metadata_pair?, <<~PATTERN (pair sym true) PATTERN |
#on_metadata(symbols, hash) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubocop/cop/rspec/metadata_style.rb', line 47 def (symbols, hash) symbols.each do |symbol| (symbol) if symbol.sym_type? end return unless hash hash.pairs.each do |pair| (pair) end end |