Skip to content

Commit

Permalink
Set processed_source before calling the cop
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed May 23, 2020
1 parent 7f7ccc4 commit 36532ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/rubocop/cop/lint/syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Syntax < Cop
def self.offenses_from_processed_source(processed_source,
config, options)
cop = new(config, options)
cop.processed_source = processed_source

cop.add_offense_from_error(processed_source.parser_error) if processed_source.parser_error

Expand Down
3 changes: 1 addition & 2 deletions lib/rubocop/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def file_offense_cache(file)
def add_redundant_disables(file, offenses, source)
if check_for_redundant_disables?(source)
redundant_cop_disable_directive(file) do |cop|
cop.processed_source = source
cop.check(offenses, source.disabled_line_ranges, source.comments)
offenses += cop.offenses
offenses += autocorrect_redundant_disables(file, source, cop,
Expand Down Expand Up @@ -181,8 +182,6 @@ def filtered_run?
end

def autocorrect_redundant_disables(file, source, cop, offenses)
cop.processed_source = source

team = Cop::Team.new(RuboCop::Cop::Registry.new, nil, @options)
team.autocorrect(source.buffer, [cop])

Expand Down

0 comments on commit 36532ba

Please sign in to comment.