Skip to content

Commit

Permalink
Improve RuboCop task definition in Rakefile
Browse files Browse the repository at this point in the history
This turns on the GitHub formatter if GH Actions is detected, which
provides nice inline annotations.
  • Loading branch information
ekohl authored and adamruzicka committed Oct 23, 2023
1 parent c99004a commit ae01eef
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

require 'rake'
require 'rake/testtask'
require 'rubocop/rake_task'

begin
require 'rubocop/rake_task'
rescue LoadError
# No Rubocop
else
RuboCop::RakeTask.new(:rubocop) do |task|
task.fail_on_error = true
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
end
end

desc 'Default: run unit tests.'
task :default => :test
Expand All @@ -20,13 +30,6 @@ end

desc 'Test Dynflow plugin.'
task :test do
Rake::Task['rubocop'].invoke if defined? RuboCop
Rake::Task['rubocop'].invoke if Rake::Task.task_defined?(:rubocop)
Rake::Task['test:core'].invoke
end

if defined? RuboCop
desc 'Run RuboCop on the lib directory'
RuboCop::RakeTask.new(:rubocop) do |task|
task.fail_on_error = true
end
end

0 comments on commit ae01eef

Please sign in to comment.