lib/rubocop/cop/cop.rb in rubocop-0.85.0 vs lib/rubocop/cop/cop.rb in rubocop-0.85.1

- old
+ new

@@ -21,11 +21,11 @@ # class CustomCop < Cop # def investigate(processed_source) # # Do custom processing # end # end - class Cop + class Cop # rubocop:disable Metrics/ClassLength extend RuboCop::AST::Sexp extend NodePattern::Macros include RuboCop::AST::Sexp include Util include IgnoredNode @@ -42,28 +42,18 @@ end attr_reader :config, :offenses, :corrections attr_accessor :processed_source # TODO: Bad design. - @registry = Registry.new - - class << self - attr_reader :registry + def self.inherited(subclass) + Registry.global.enlist(subclass) end - def self.all - registry.without_department(:Test).cops + def self.exclude_from_registry + Registry.global.dismiss(self) end - def self.qualified_cop_name(name, origin) - registry.qualified_cop_name(name, origin) - end - - def self.inherited(subclass) - registry.enlist(subclass) - end - def self.badge @badge ||= Badge.for(name) end def self.cop_name @@ -242,9 +232,26 @@ # Overriding this method allows the cop to indicate to RuboCop's # ResultCache system when those external dependencies change, # ie when the ResultCache should be invalidated. def external_dependency_checksum nil + end + + ### Deprecated registry access + + # @deprecated Use Registry.global + def self.registry + Registry.global + end + + # @deprecated Use Registry.all + def self.all + Registry.all + end + + # @deprecated Use Registry.qualified_cop_name + def self.qualified_cop_name(name, origin) + Registry.qualified_cop_name(name, origin) end private def find_message(node, message)