Skip to content

Commit 661dc80

Browse files
committed
🔨 Better rake tasks for development
1 parent b43ab9a commit 661dc80

File tree

1 file changed

+78
-38
lines changed

1 file changed

+78
-38
lines changed

Rakefile

Lines changed: 78 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,120 @@
22

33
require "bundler/gem_tasks"
44

5-
require "version_gem"
5+
defaults = []
66

7+
# Setup Kettle Soup Cover
78
begin
8-
require "rspec/core/rake_task"
9+
require "kettle-soup-cover"
910

10-
RSpec::Core::RakeTask.new(:spec)
11+
Kettle::Soup::Cover.install_tasks
12+
# NOTE: Coverage on CI is configured independent of this task.
13+
# This task is for local development, as it opens results in browser
14+
defaults << "coverage" unless Kettle::Soup::Cover::IS_CI
1115
rescue LoadError
12-
task(:spec) do
13-
warn("RSpec is disabled")
16+
desc("(stub) coverage is unavailable")
17+
task("coverage") do
18+
warn("NOTE: kettle-soup-cover isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
1419
end
1520
end
1621

17-
desc "alias test task to spec"
18-
task test: :spec
19-
22+
# Setup stone_checksums
2023
begin
21-
require "reek/rake/task"
24+
require "stone_checksums"
2225

23-
Reek::Rake::Task.new do |t|
24-
t.fail_on_error = true
25-
t.verbose = false
26-
t.source_files = "{spec,spec_ignored,spec_orms,lib}/**/*.rb"
27-
end
26+
GemChecksums.install_tasks
2827
rescue LoadError
29-
task(:reek) do
30-
warn("reek is disabled")
28+
desc("(stub) build:generate_checksums is unavailable")
29+
task("build:generate_checksums") do
30+
warn("NOTE: stone_checksums isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
3131
end
3232
end
3333

34+
# Setup Bundle Audit
3435
begin
35-
require "yard-junk/rake"
36+
require "bundler/audit/task"
3637

37-
YardJunk::Rake.define_task
38+
Bundler::Audit::Task.new
39+
defaults.push("bundle:audit:update", "bundle:audit")
3840
rescue LoadError
39-
task("yard:junk") do
40-
warn("yard:junk is disabled")
41+
desc("(stub) bundle:audit is unavailable")
42+
task("bundle:audit") do
43+
warn("NOTE: bundler-audit isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
44+
end
45+
desc("(stub) bundle:audit:update is unavailable")
46+
task("bundle:audit:update") do
47+
warn("NOTE: bundler-audit isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
4148
end
4249
end
4350

4451
begin
45-
require "yard"
52+
require "rspec/core/rake_task"
4653

47-
YARD::Rake::YardocTask.new(:yard)
54+
RSpec::Core::RakeTask.new(:spec)
55+
defaults << "spec"
4856
rescue LoadError
49-
task(:yard) do
50-
warn("yard is disabled")
57+
desc("spec task stub")
58+
task(:spec) do
59+
warn("NOTE: rspec isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
5160
end
5261
end
5362

63+
desc "run spec task with test task"
64+
task test: :spec
65+
66+
# Setup Reek
5467
begin
55-
require "rubocop/lts"
56-
Rubocop::Lts.install_tasks
68+
require "reek/rake/task"
69+
70+
Reek::Rake::Task.new do |t|
71+
t.fail_on_error = true
72+
t.verbose = false
73+
t.source_files = "{lib,spec}/**/*.rb"
74+
end
75+
defaults << "reek"
5776
rescue LoadError
58-
task(:rubocop_gradual) do
59-
warn("RuboCop (Gradual) is disabled")
77+
desc("(stub) reek is unavailable")
78+
task(:reek) do
79+
warn("NOTE: reek isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
6080
end
6181
end
6282

83+
# Setup Yard
6384
begin
64-
require "kettle-soup-cover"
65-
Kettle::Soup::Cover.install_tasks
85+
require "yard"
86+
87+
YARD::Rake::YardocTask.new(:yard) do |t|
88+
t.files = [
89+
# Splats (alphabetical)
90+
"lib/**/*.rb",
91+
]
92+
end
93+
defaults << "yard"
6694
rescue LoadError
67-
desc("alias coverage task to spec (coverage unavailable)")
68-
task(coverage: :spec)
95+
desc("(stub) yard is unavailable")
96+
task(:yard) do
97+
warn("NOTE: yard isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
98+
end
6999
end
70100

71101
begin
72-
require "gem_checksums"
73-
GemChecksums.install_tasks
102+
require "rubocop/gradual/rake_task"
103+
104+
RuboCop::Gradual::RakeTask.new
105+
106+
defaults << "rubocop_gradual"
107+
108+
namespace(:rubocop_gradual) do
109+
desc("dogfood internal rubocop configs")
110+
task(:dogfood) do
111+
%x(bin/rubocop-gradual -c .rubocop-dogfood.yml)
112+
end
113+
end
74114
rescue LoadError
75-
task("build:generate_checksums") do
76-
warn("gem_checksums is not available")
115+
desc("(stub) rubocop_gradual is unavailable")
116+
task(:rubocop_gradual) do
117+
warn("NOTE: rubocop-gradual isn't installed, or is disabled for #{RUBY_VERSION} in the current environment")
77118
end
78119
end
79120

80-
# coverage task will open coverage in browser locally
81-
task default: %i[coverage rubocop_gradual:autocorrect yard yard:junk]
121+
task default: defaults

0 commit comments

Comments
 (0)