Class: RuboCounsel::CopEntry
- Inherits:
-
Object
- Object
- RuboCounsel::CopEntry
- Defined in:
- lib/rubocounsel/cop_entry.rb
Overview
Represents a single cop with its configuration and examples.
This is an entry in the CopCatalog - a data object that combines:
- The cop class (from Registry)
- Its configuration (from RuboCop's default config)
- Its examples (from YARD parsing)
- Computed configurable attributes
Constant Summary collapse
- METADATA_KEYS =
Keys in cop configuration that are metadata, not user-configurable options.
[ "Description", "StyleGuide", "Enabled", "VersionAdded", "VersionChanged", "VersionRemoved", "Reference", "Safe", "SafeAutoCorrect" ].freeze
Instance Attribute Summary collapse
-
#cop_class ⇒ Object
readonly
Returns the value of attribute cop_class.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
Instance Method Summary collapse
- #configurable? ⇒ Boolean
- #configurable_attributes ⇒ Object
- #configuration ⇒ Object
- #cop_name ⇒ Object
-
#initialize(cop_class, examples: []) ⇒ CopEntry
constructor
A new instance of CopEntry.
Constructor Details
#initialize(cop_class, examples: []) ⇒ CopEntry
Returns a new instance of CopEntry.
29 30 31 32 |
# File 'lib/rubocounsel/cop_entry.rb', line 29 def initialize(cop_class, examples: []) @cop_class = cop_class @examples = examples end |
Instance Attribute Details
#cop_class ⇒ Object (readonly)
Returns the value of attribute cop_class.
27 28 29 |
# File 'lib/rubocounsel/cop_entry.rb', line 27 def cop_class @cop_class end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
27 28 29 |
# File 'lib/rubocounsel/cop_entry.rb', line 27 def examples @examples end |
Instance Method Details
#configurable? ⇒ Boolean
46 47 48 |
# File 'lib/rubocounsel/cop_entry.rb', line 46 def configurable? configurable_attributes.any?(&:promptable?) end |
#configurable_attributes ⇒ Object
42 43 44 |
# File 'lib/rubocounsel/cop_entry.rb', line 42 def configurable_attributes @configurable_attributes ||= build_configurable_attributes end |
#configuration ⇒ Object
38 39 40 |
# File 'lib/rubocounsel/cop_entry.rb', line 38 def configuration @configuration ||= RuboCop::ConfigLoader.default_configuration[cop_name].to_h end |
#cop_name ⇒ Object
34 35 36 |
# File 'lib/rubocounsel/cop_entry.rb', line 34 def cop_name @cop_class.cop_name end |