Class: RuboCop::ConfigObsoletion::CopRule Private

Inherits:
Rule
  • Object
show all
Defined in:
lib/rubocop/config_obsoletion/cop_rule.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.

Base class for ConfigObsoletion rules relating to cops

Direct Known Subclasses

ExtractedCop, RemovedCop, RenamedCop, SplitCop

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Rule

#parameter_rule?

Constructor Details

#initialize(config, old_name) ⇒ CopRule

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



10
11
12
13
# File 'lib/rubocop/config_obsoletion/cop_rule.rb', line 10

def initialize(config, old_name)
  super(config)
  @old_name = old_name
end

Instance Attribute Details

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



8
9
10
# File 'lib/rubocop/config_obsoletion/cop_rule.rb', line 8

def old_name
  @old_name
end

Instance Method Details

#cop_rule?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.

Returns:

  • (Boolean)


15
16
17
# File 'lib/rubocop/config_obsoletion/cop_rule.rb', line 15

def cop_rule?
  true
end

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



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

def message
  rule_message + "\n(obsolete configuration found in #{smart_loaded_path}, please update it)"
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.

Returns:

  • (Boolean)


28
29
30
# File 'lib/rubocop/config_obsoletion/cop_rule.rb', line 28

def violated?
  config.key?(old_name) || config.key?(Cop::Badge.parse(old_name).cop_name)
end

#warning?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.

Cop rules currently can only be failures, not warnings

Returns:

  • (Boolean)


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

def warning?
  false
end