lib/rubocop/cop/cop.rb in rubocop-1.41.1 vs lib/rubocop/cop/cop.rb in rubocop-1.42.0
- old
+ new
@@ -20,10 +20,38 @@
rescue StandardError => e
raise ErrorWithAnalyzedFileLocation.new(cause: e, node: node, cop: cop)
end
end
+ def self.support_autocorrect?
+ method_defined?(:autocorrect)
+ end
+
+ def self.joining_forces
+ return unless method_defined?(:join_force?)
+
+ cop = new
+ Force.all.select { |force_class| cop.join_force?(force_class) }
+ 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
+
def add_offense(node_or_range, location: :expression, message: nil, severity: nil, &block)
@v0_argument = node_or_range
range = find_location(node_or_range, location)
if block.nil? && !support_autocorrect?
super(range, message: message, severity: severity)
@@ -43,21 +71,10 @@
def support_autocorrect?
# warn 'deprecated, use cop.class.support_autocorrect?' TODO
self.class.support_autocorrect?
end
- def self.support_autocorrect?
- method_defined?(:autocorrect)
- end
-
- def self.joining_forces
- return unless method_defined?(:join_force?)
-
- cop = new
- Force.all.select { |force_class| cop.join_force?(force_class) }
- end
-
# @deprecated
def corrections
# warn 'Cop#corrections is deprecated' TODO
return [] unless @last_corrector
@@ -72,26 +89,9 @@
# Called after all on_... have been called
def on_investigation_end
investigate_post_walk(processed_source) if respond_to?(:investigate_post_walk)
super
- 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 begin_investigation(processed_source)