From dc1bd1ca8970d869386771408f53c84f477ea4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Wed, 27 Jul 2022 10:57:26 +0200 Subject: [PATCH] Don't try to autocorrect linters that don't support autocorrect --- lib/erb_lint/corrector.rb | 2 +- spec/erb_lint/cli_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/erb_lint/corrector.rb b/lib/erb_lint/corrector.rb index d24b3939..7ccecf5b 100644 --- a/lib/erb_lint/corrector.rb +++ b/lib/erb_lint/corrector.rb @@ -12,7 +12,7 @@ def initialize(processed_source, offenses) def corrections @corrections ||= @offenses.map do |offense| - offense.linter.autocorrect(@processed_source, offense) + offense.linter.autocorrect(@processed_source, offense) if offense.linter.class.support_autocorrect? end.compact end diff --git a/spec/erb_lint/cli_spec.rb b/spec/erb_lint/cli_spec.rb index 8b45ddb2..f1d30d01 100644 --- a/spec/erb_lint/cli_spec.rb +++ b/spec/erb_lint/cli_spec.rb @@ -514,9 +514,9 @@ def run(processed_source) end context "when autocorrecting an error" do - # We assume that linter_without_errors is not autocorrectable... + # We assume that linter_with_errors is not autocorrectable... let(:args) do - ["--enable-linter", "final_newline,linter_without_errors", "--stdin", linted_file, "--autocorrect"] + ["--enable-linter", "final_newline,linter_with_errors", "--stdin", linted_file, "--autocorrect"] end it "tells the user it is autocorrecting" do