Skip to content

Commit

Permalink
Don't use deprecated corrector apis
Browse files Browse the repository at this point in the history
Closes #368

This is pretty much just a compatibility layer in itself.

Cops here are still declared with the old style (`autocorrect` instance method for example)
but rewriting that all is not trivial and also works just fine
  • Loading branch information
Earlopain committed Sep 20, 2024
1 parent 48ffca8 commit 7fddf50
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/erb_lint/corrector.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

require "rubocop/cop/legacy/corrector"

module ERBLint
class Corrector
attr_reader :processed_source, :offenses, :corrected_content

def initialize(processed_source, offenses)
@processed_source = processed_source
@offenses = offenses
corrector = RuboCop::Cop::Corrector.new(@processed_source.source_buffer)
correct!(corrector)
@corrected_content = corrector.rewrite
end

Expand All @@ -18,8 +18,10 @@ def corrections
end.compact
end

def corrector
::RuboCop::Cop::Legacy::Corrector.new(@processed_source.source_buffer, corrections)
def correct!(corrector)
corrections.each do |correction|
correction.call(corrector)
end
end
end
end

0 comments on commit 7fddf50

Please sign in to comment.