Class: RuboCop::ConfigObsoletion::RemovedCop Private
- Defined in:
- lib/rubocop/config_obsoletion/removed_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 removing a previously defined cop.
Constant Summary collapse
- BASE_MESSAGE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'The `%<old_name>s` cop has been removed'
Instance Attribute Summary collapse
- #metadata ⇒ Object readonly private
- #old_name ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(config, old_name, metadata) ⇒ RemovedCop
constructor
private
A new instance of RemovedCop.
- #rule_message ⇒ Object private
Methods inherited from CopRule
#cop_rule?, #message, #violated?, #warning?
Methods inherited from Rule
#cop_rule?, #parameter_rule?, #violated?
Constructor Details
#initialize(config, old_name, metadata) ⇒ RemovedCop
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 RemovedCop.
13 14 15 16 |
# File 'lib/rubocop/config_obsoletion/removed_cop.rb', line 13 def initialize(config, old_name, ) super(config, old_name) @metadata = .is_a?(Hash) ? : {} end |
Instance Attribute Details
#metadata ⇒ 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/removed_cop.rb', line 9 def @metadata end |
#old_name ⇒ 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/removed_cop.rb', line 9 def old_name @old_name 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.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubocop/config_obsoletion/removed_cop.rb', line 18 def base = format(BASE_MESSAGE, old_name: old_name) if reason "#{base} since #{reason.chomp}." elsif alternatives "#{base}. Please use #{to_sentence(alternatives, connector: 'and/or')} instead." else "#{base}." end end |