Class: RuboCounsel::CopEntry

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_classObject (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

#examplesObject (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

Returns:



46
47
48
# File 'lib/rubocounsel/cop_entry.rb', line 46

def configurable?
  configurable_attributes.any?(&:promptable?)
end

#configurable_attributesObject



42
43
44
# File 'lib/rubocounsel/cop_entry.rb', line 42

def configurable_attributes
  @configurable_attributes ||= build_configurable_attributes
end

#configurationObject



38
39
40
# File 'lib/rubocounsel/cop_entry.rb', line 38

def configuration
  @configuration ||= RuboCop::ConfigLoader.default_configuration[cop_name].to_h
end

#cop_nameObject



34
35
36
# File 'lib/rubocounsel/cop_entry.rb', line 34

def cop_name
  @cop_class.cop_name
end