Skip to content

Commit

Permalink
Move parse method into new Cop API
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Apr 16, 2021
1 parent b4e6aaa commit 9455d4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 5 additions & 0 deletions lib/rubocop/cop/base.rb
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions lib/rubocop/cop/cop.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 9455d4a

Please sign in to comment.