Class: RuboCop::ConfigObsoletion::RemovedCop Private

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

Instance Method Summary collapse

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

#metadataObject (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_nameObject (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_messageObject

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 rule_message
  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