Skip to content

Commit 4fa654a

Browse files
committed
Add lint/security/doc-check tooling from next, without CI wiring
Pull over the rake tasks CLAUDE.md already assumes exist here (lint, security, doc:check/doc:lint/doc:links) plus their gemspec dev dependencies (awesome_bot, mdl, bundler-audit) and mdl config, matching next's tooling. Available to run locally/manually. Deliberately not wired into CI yet: rake lint and rake doc:check both fail against master's pre-existing content (the RuboCop offenses noted in earlier commits this session, and README.md's older heading/code- block style predating these markdown-lint conventions). Wiring a new CI job today would go red immediately on unrelated debt; that cleanup is separate, larger scope. rake security passes clean as-is.
1 parent 15360be commit 4fa654a

5 files changed

Lines changed: 86 additions & 1 deletion

File tree

.mdlrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style "#{File.join(File.dirname(__FILE__), 'mdl_style.rb')}"

Gemfile.lock

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,35 @@ GEM
88
remote: https://rubygems.org/
99
specs:
1010
ast (2.4.2)
11+
awesome_bot (1.20.0)
12+
parallel (= 1.20.1)
13+
bundler-audit (0.9.3)
14+
bundler (>= 1.2.0)
15+
thor (~> 1.0)
16+
chef-utils (19.3.15)
17+
concurrent-ruby
18+
concurrent-ruby (1.3.8)
1119
date (3.4.1)
1220
diff-lcs (1.5.1)
1321
docile (1.4.1)
1422
json (2.21.2)
23+
kramdown (2.5.2)
24+
rexml (>= 3.4.4)
25+
kramdown-parser-gfm (1.1.0)
26+
kramdown (~> 2.0)
1527
language_server-protocol (3.17.0.3)
16-
parallel (1.26.3)
28+
mdl (0.14.0)
29+
kramdown (~> 2.3)
30+
kramdown-parser-gfm (~> 1.1)
31+
mixlib-cli (~> 2.1, >= 2.1.1)
32+
mixlib-config (>= 2.2.1, < 4)
33+
mixlib-shellout
34+
mixlib-cli (2.1.8)
35+
mixlib-config (3.0.27)
36+
tomlrb
37+
mixlib-shellout (3.3.8)
38+
chef-utils
39+
parallel (1.20.1)
1740
parser (3.3.6.0)
1841
ast (~> 2.4.1)
1942
racc
@@ -27,6 +50,7 @@ GEM
2750
rdoc (6.10.0)
2851
psych (>= 4.0.0)
2952
regexp_parser (2.9.3)
53+
rexml (3.4.4)
3054
rspec (3.13.0)
3155
rspec-core (~> 3.13.0)
3256
rspec-expectations (~> 3.13.0)
@@ -70,6 +94,8 @@ GEM
7094
stringio (3.1.2)
7195
test-unit (3.6.7)
7296
power_assert
97+
thor (1.5.0)
98+
tomlrb (2.0.4)
7399
unicode-display_width (3.1.2)
74100
unicode-emoji (~> 4.0, >= 4.0.4)
75101
unicode-emoji (4.0.4)
@@ -79,7 +105,10 @@ PLATFORMS
79105
ruby
80106

81107
DEPENDENCIES
108+
awesome_bot (~> 1.20)
82109
bundler (~> 2.3)
110+
bundler-audit (~> 0.9)
111+
mdl (~> 0.14)
83112
rake (~> 13.2)
84113
rdoc (~> 6.10)
85114
rspec (~> 3.0, >= 3.13)

Rakefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ GEM_SPEC = Bundler.load_gemspec(File.join(__dir__, 'rubytree.gemspec'))
4242
PKG_NAME = GEM_SPEC.name
4343
PKG_VER = GEM_SPEC.version
4444
GEM_NAME = "#{PKG_NAME}-#{PKG_VER}.gem"
45+
MARKDOWN_FILES = Dir['**/*.md'].reject do |path|
46+
path.start_with?('vendor/', 'pkg/')
47+
end.sort
4548

4649
desc 'Default Task (Run the tests)'
4750
task :default do
@@ -98,6 +101,19 @@ namespace :doc do # ................................ Documentation
98101
task :clobber_yard do
99102
rm_rf 'doc'
100103
end
104+
105+
desc 'Run markdown lint checks'
106+
task :lint do
107+
sh('mdl', '--config', '.mdlrc', *MARKDOWN_FILES)
108+
end
109+
110+
desc 'Validate http(s) links in markdown files'
111+
task :links do
112+
sh('awesome_bot', *MARKDOWN_FILES, '--allow-redirect', '--allow-dupe')
113+
end
114+
115+
desc 'Run markdown lint and link checks'
116+
task check: %i[lint links]
101117
end
102118

103119
desc 'Run the unit tests'
@@ -181,3 +197,32 @@ RuboCop::RakeTask.new(:rubocop) do |t|
181197
t.requires << 'rubocop-rake'
182198
t.requires << 'rubocop-rspec'
183199
end
200+
201+
# ................................ Gem metadata
202+
desc 'Validate gemspec metadata and required fields'
203+
task :gemspec do
204+
GEM_SPEC.validate
205+
puts 'Gemspec is valid.'
206+
end
207+
208+
# ................................ Linting
209+
desc 'Run lint checks'
210+
task lint: %i[gemspec rubocop]
211+
212+
# ................................ Security checks
213+
desc 'Run security checks (bundler-audit, semgrep)'
214+
task :security do
215+
sh('bundle', 'exec', 'bundler-audit', 'check', '--update')
216+
217+
semgrep_available = system('command -v semgrep >/dev/null 2>&1')
218+
unless semgrep_available
219+
warn 'WARN: semgrep not found; skipping semgrep security scan.'
220+
return
221+
end
222+
223+
env = {}
224+
default_cert = '/etc/ssl/cert.pem'
225+
env['SSL_CERT_FILE'] = default_cert if ENV['SSL_CERT_FILE'].nil? && File.exist?(default_cert)
226+
227+
sh(env, 'semgrep', '--config', 'p/r2c-security-audit', '--config', 'p/ruby', 'lib')
228+
end

mdl_style.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
all
4+
rule 'MD029', style: 'one_or_ordered'
5+
exclude_rule 'MD032'
6+
exclude_rule 'MD041'
7+
exclude_rule 'MD013'

rubytree.gemspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ Gem::Specification.new do |s|
6767
s.add_runtime_dependency 'json', '~> 2.0', '>= 2.21.2'
6868

6969
# NOTE: Rake is added as a development and test dependency in the Gemfile.
70+
s.add_development_dependency 'awesome_bot', '~> 1.20'
7071
s.add_development_dependency 'bundler', '~> 2.3'
72+
s.add_development_dependency 'bundler-audit', '~> 0.9'
73+
s.add_development_dependency 'mdl', '~> 0.14'
7174
s.add_development_dependency 'rake', '~> 13.2'
7275
s.add_development_dependency 'rdoc', '~> 6.10'
7376
s.add_development_dependency 'rspec', '~> 3.0', '>= 3.13'

0 commit comments

Comments
 (0)