class RuboCop::ConfigObsoletion::RemovedCop

Encapsulation of a ConfigObsoletion rule for removing a previously defined cop. @api private

Constants

BASE_MESSAGE

Attributes

metadata[R]
old_name[R]

Public Class Methods

new(config, old_name, metadata) click to toggle source
Calls superclass method RuboCop::ConfigObsoletion::CopRule::new
# File lib/rubocop/config_obsoletion/removed_cop.rb, line 13
def initialize(config, old_name, metadata)
  super(config, old_name)
  @metadata = metadata.is_a?(Hash) ? metadata : {}
end

Public Instance Methods

rule_message() click to toggle source
# 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

Private Instance Methods

alternatives() click to toggle source
# File lib/rubocop/config_obsoletion/removed_cop.rb, line 36
def alternatives
  Array(metadata['alternatives']).map { |name| "`#{name}`" }
end
reason() click to toggle source
# File lib/rubocop/config_obsoletion/removed_cop.rb, line 32
def reason
  metadata['reason']
end