From be29be73b81ece165aa95fba59269741f8834898 Mon Sep 17 00:00:00 2001 From: gemmaro Date: Tue, 4 Oct 2022 22:12:55 +0900 Subject: [PATCH] Fix RuboCop task in Rakefile If the RuboCop version is 1.31 or later then use `rubocop:autocorrect` task instead of deprecated `rubocop:auto_correct` in the `Rakefile`. Otherwise use the conventional `rubocop:auto_correct` task. Note that the older RuboCop doesn't have `RuboCop::Version` module, so the condition `RuboCop.const_defined?(:Version)` is necessary. --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 2d0be33faa..24d6e10ba4 100644 --- a/Rakefile +++ b/Rakefile @@ -106,5 +106,7 @@ else RuboCop::RakeTask.new(:rubocop) do |t| t.options = [*parsed_files] end - task :build => [:generate, "rubocop:auto_correct"] + is_newer_rubocop = RuboCop.const_defined?(:Version) && Gem::Version.new(RuboCop::Version::STRING) >= '1.31.0' + rubocop_task = is_newer_rubocop ? "rubocop:autocorrect" : "rubocop:auto_correct" + task :build => [:generate, rubocop_task] end