From 85b6d5b2fc494eed3a49c4ce203bca0edad0a103 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Fri, 16 Apr 2021 15:34:16 -0400 Subject: [PATCH] Move `parse` method into new Cop API --- lib/rubocop/cop/base.rb | 5 +++++ lib/rubocop/cop/cop.rb | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/rubocop/cop/base.rb b/lib/rubocop/cop/base.rb index 7953ec217ed..fbbec231bdf 100644 --- a/lib/rubocop/cop/base.rb +++ b/lib/rubocop/cop/base.rb @@ -230,6 +230,11 @@ def excluded_file?(file) !relevant_file?(file) end + # There should be very limited reasons for a Cop to do it's own parsing + def parse(source, path = nil) + ProcessedSource.new(source, target_ruby_version, path) + end + ### Persistence # Override if your cop should be called repeatedly for multiple investigations diff --git a/lib/rubocop/cop/cop.rb b/lib/rubocop/cop/cop.rb index 80af3dea948..9e6cbf7b02f 100644 --- a/lib/rubocop/cop/cop.rb +++ b/lib/rubocop/cop/cop.rb @@ -93,12 +93,6 @@ def self.qualified_cop_name(name, origin) Registry.qualified_cop_name(name, origin) end - # @deprecated - # Open issue if there's a valid use case to include this in Base - def parse(source, path = nil) - ProcessedSource.new(source, target_ruby_version, path) - end - private def begin_investigation(processed_source)