From 6280c79c2ab9919f29164a2228da8a5b1a0db8da Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:47:50 +0100 Subject: [PATCH] Don't use deprecated corrector apis (#378) 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 --- lib/erb_lint/corrector.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/erb_lint/corrector.rb b/lib/erb_lint/corrector.rb index 804d03e..4488cd3 100644 --- a/lib/erb_lint/corrector.rb +++ b/lib/erb_lint/corrector.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "rubocop/cop/legacy/corrector" - module ERBLint class Corrector attr_reader :processed_source, :offenses, :corrected_content @@ -9,6 +7,8 @@ class Corrector 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 @@ -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