Class: RuboCop::ConfigObsoletion::ExtractedCop Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
RuboCop::ConfigObsoletion::CopRule
|
Defined in: | lib/rubocop/config_obsoletion/extracted_cop.rb |
Overview
Encapsulation of a ConfigObsoletion rule for splitting a cop’s functionality into multiple new cops.
Class Method Summary
- .new(config, old_name, gem) ⇒ ExtractedCop constructor Internal use only
CopRule
- Inherited
Rule
- Inherited
Instance Attribute Summary
- #department readonly Internal use only
- #gem readonly Internal use only
- #violated? ⇒ Boolean readonly Internal use only
- #feature_loaded? ⇒ Boolean readonly private Internal use only
CopRule
- Inherited
#cop_rule?, #old_name, #violated?, | |
#warning? | Cop rules currently can only be failures, not warnings. |
Rule
- Inherited
#cop_rule? | Does this rule relate to cops? |
#parameter_rule? | Does this rule relate to parameters? |
#violated?, #config |
Instance Method Summary
- #rule_message Internal use only
- #affected_cops private Internal use only
CopRule
- Inherited
Rule
- Inherited
Instance Attribute Details
#department (readonly)
[ GitHub ]# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 9
attr_reader :gem, :department
#feature_loaded? ⇒ Boolean
(readonly, private)
#gem (readonly)
[ GitHub ]# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 9
attr_reader :gem, :department
#violated? ⇒ Boolean
(readonly)
# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 17
def violated? return false if feature_loaded? affected_cops.any? end
Instance Method Details
#affected_cops (private)
[ GitHub ]# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 32
def affected_cops return old_name unless old_name.end_with?('*') # Handle whole departments (expressed as `Department/*`) config.keys.select do |key| key == department || key.start_with?("#{department}/") end end
#rule_message
[ GitHub ]# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 23
def msg = '%<name>s been extracted to the `%<gem>s` gem.' format(msg, name: affected_cops.size > 1 ? "`#{department}` cops have" : "`#{old_name}` has", gem: gem) end