Module: Metz::CopMetadata
- Included in:
- RuboCop::Cop::Metz::ClassesTooLong, RuboCop::Cop::Metz::ControllersTooManyDirectCollaborators, RuboCop::Cop::Metz::DemeterTrainWreck, RuboCop::Cop::Metz::MethodsTooLong, RuboCop::Cop::Metz::MethodsTooManyParameters
- Defined in:
- lib/metz/cop_metadata.rb
Overview
Metadata DSL for Metz cops. Provides class-level setter/reader macros for
why_it_matters, fix_safety, and suggested_next_moves. Works whether
included (instance-style sub-modules) or extended onto the class.
Public contract for a cop class that never invokes any setter:
- why_it_matters -> "" (empty string)
- fix_safety -> :manual (the safest, no-autocorrect tier)
- suggested_next_moves -> [] (empty, frozen array)
Constant Summary collapse
- DEFAULT_WHY_IT_MATTERS =
""- DEFAULT_FIX_SAFETY =
:manual- DEFAULT_SUGGESTED_NEXT_MOVES =
[].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #fix_safety(value = UNSET) ⇒ Object
- #metz_metadata ⇒ Object
- #suggested_next_moves(value = UNSET) ⇒ Object
- #why_it_matters(value = UNSET) ⇒ Object
Class Method Details
.included(base) ⇒ Object
20 21 22 |
# File 'lib/metz/cop_metadata.rb', line 20 def self.included(base) base.extend(self) end |
Instance Method Details
#fix_safety(value = UNSET) ⇒ Object
30 31 32 33 34 |
# File 'lib/metz/cop_metadata.rb', line 30 def fix_safety(value = UNSET) return @metz_fix_safety = value unless UNSET.equal?(value) defined?(@metz_fix_safety) ? @metz_fix_safety : DEFAULT_FIX_SAFETY end |
#metz_metadata ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/metz/cop_metadata.rb', line 42 def { why_it_matters: why_it_matters, fix_safety: fix_safety, suggested_next_moves: suggested_next_moves } end |
#suggested_next_moves(value = UNSET) ⇒ Object
36 37 38 39 40 |
# File 'lib/metz/cop_metadata.rb', line 36 def suggested_next_moves(value = UNSET) return @metz_suggested_next_moves = value unless UNSET.equal?(value) defined?(@metz_suggested_next_moves) ? @metz_suggested_next_moves : DEFAULT_SUGGESTED_NEXT_MOVES end |
#why_it_matters(value = UNSET) ⇒ Object
24 25 26 27 28 |
# File 'lib/metz/cop_metadata.rb', line 24 def why_it_matters(value = UNSET) return @metz_why_it_matters = value unless UNSET.equal?(value) defined?(@metz_why_it_matters) ? @metz_why_it_matters : DEFAULT_WHY_IT_MATTERS end |