Class: RuboCop::ConfigObsoletion::ExtractedCop Private
- Defined in:
- lib/rubocop/config_obsoletion/extracted_cop.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Encapsulation of a ConfigObsoletion rule for splitting a cop’s functionality into multiple new cops.
Instance Attribute Summary collapse
- #department ⇒ Object readonly private
- #gem ⇒ Object readonly private
Attributes inherited from CopRule
Instance Method Summary collapse
-
#initialize(config, old_name, gem) ⇒ ExtractedCop
constructor
private
A new instance of ExtractedCop.
- #rule_message ⇒ Object private
- #violated? ⇒ Boolean private
Methods inherited from CopRule
#cop_rule?, #message, #warning?
Methods inherited from Rule
Constructor Details
#initialize(config, old_name, gem) ⇒ ExtractedCop
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ExtractedCop.
11 12 13 14 15 |
# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 11 def initialize(config, old_name, gem) super(config, old_name) @department, * = old_name.rpartition('/') @gem = gem end |
Instance Attribute Details
#department ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 9 def department @department end |
#gem ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 9 def gem @gem end |
Instance Method Details
#rule_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 |
# 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 |
#violated? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 |
# File 'lib/rubocop/config_obsoletion/extracted_cop.rb', line 17 def violated? return false if feature_loaded? affected_cops.any? end |