Class: RuboCop::ConfigObsoletion Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/config_obsoletion.rb,
lib/rubocop/config_obsoletion/rule.rb,
lib/rubocop/config_obsoletion/cop_rule.rb,
lib/rubocop/config_obsoletion/split_cop.rb,
lib/rubocop/config_obsoletion/removed_cop.rb,
lib/rubocop/config_obsoletion/renamed_cop.rb,
lib/rubocop/config_obsoletion/extracted_cop.rb,
lib/rubocop/config_obsoletion/parameter_rule.rb,
lib/rubocop/config_obsoletion/changed_parameter.rb,
lib/rubocop/config_obsoletion/changed_enforced_styles.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.

This class handles obsolete configuration.

Defined Under Namespace

Classes: ChangedEnforcedStyles, ChangedParameter, CopRule, ExtractedCop, ParameterRule, RemovedCop, RenamedCop, Rule, SplitCop

Constant Summary collapse

DEFAULT_RULES_FILE =

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.

File.join(ConfigLoader::RUBOCOP_HOME, 'config', 'obsoletion.yml')
COP_RULE_CLASSES =

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.

{
  'renamed' => RenamedCop,
  'removed' => RemovedCop,
  'split' => SplitCop,
  'extracted' => ExtractedCop
}.freeze
PARAMETER_RULE_CLASSES =

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.

{
  'changed_parameters' => ChangedParameter,
  'changed_enforced_styles' => ChangedEnforcedStyles
}.freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ConfigObsoletion

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 ConfigObsoletion.



33
34
35
36
37
# File 'lib/rubocop/config_obsoletion.rb', line 33

def initialize(config)
  @config = config
  @rules = load_rules
  @warnings = []
end

Class Attribute Details

.filesObject

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.



22
23
24
# File 'lib/rubocop/config_obsoletion.rb', line 22

def files
  @files
end

Instance Attribute Details

#rulesObject (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.



19
20
21
# File 'lib/rubocop/config_obsoletion.rb', line 19

def rules
  @rules
end

#warningsObject (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.



19
20
21
# File 'lib/rubocop/config_obsoletion.rb', line 19

def warnings
  @warnings
end

Class Method Details

.legacy_cop_namesObject

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.



24
25
26
27
# File 'lib/rubocop/config_obsoletion.rb', line 24

def legacy_cop_names
  # Used by DepartmentName#qualified_legacy_cop_name
  new(Config.new).rules.select(&:cop_rule?).map(&:old_name)
end

Instance Method Details

#reject_obsolete!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.

Raises:



39
40
41
42
43
44
# File 'lib/rubocop/config_obsoletion.rb', line 39

def reject_obsolete!
  messages = obsoletions.flatten.compact
  return if messages.empty?

  raise ValidationError, messages.join("\n")
end