Skip to content

Commit

Permalink
Fix RuboCop task in Rakefile
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gemmaro committed Oct 4, 2022
1 parent d12272b commit be29be7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit be29be7

Please sign in to comment.