From 61267498f2d780a2976b90ae7621328cd111513c Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Wed, 9 Nov 2022 19:57:25 +0100 Subject: [PATCH 1/2] Bump and loosen rubocop version in rubocop-next bundle --- gemfiles/Gemfile.rubocop-next | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gemfiles/Gemfile.rubocop-next b/gemfiles/Gemfile.rubocop-next index 16894d8d..48f29505 100644 --- a/gemfiles/Gemfile.rubocop-next +++ b/gemfiles/Gemfile.rubocop-next @@ -2,4 +2,4 @@ eval_gemfile "../Gemfile" -gem "rubocop", "~> 1.37.1" +gem "rubocop", ">= 1.38.0" From 9b7dec10f51cd5e505347aded25d4d7e1aec94c4 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Wed, 9 Nov 2022 20:34:57 +0100 Subject: [PATCH 2/2] Make RuboCop linter work with RuboCop 1.38 This version of RuboCop needs registry and config attributes to be set on the ProcessedSource object. These attributes do not exist in earlier versions of RuboCop. --- lib/erb_lint/linters/rubocop.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/erb_lint/linters/rubocop.rb b/lib/erb_lint/linters/rubocop.rb index 7cefe970..6f99058d 100644 --- a/lib/erb_lint/linters/rubocop.rb +++ b/lib/erb_lint/linters/rubocop.rb @@ -131,11 +131,17 @@ def tempfile_from(filename, content) end def rubocop_processed_source(content, filename) - ::RuboCop::ProcessedSource.new( + source = ::RuboCop::ProcessedSource.new( content, @rubocop_config.target_ruby_version, filename ) + if ::RuboCop::Version::STRING.to_f >= 1.38 + registry = RuboCop::Cop::Registry.global + source.registry = registry + source.config = @rubocop_config + end + source end def cop_classes