Skip to content

Rewrite lint-no-raw-mdc as Ruby (was bash) - #21

Merged
ronaldtse merged 3 commits into
mainfrom
chore/lint-no-raw-mdc-in-ruby
Jul 24, 2026
Merged

Rewrite lint-no-raw-mdc as Ruby (was bash)#21
ronaldtse merged 3 commits into
mainfrom
chore/lint-no-raw-mdc-in-ruby

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

bin/lint-no-raw-mdc was a bash script. For a Ruby library this is the
wrong choice — it requires bash on PATH (works on Linux/macOS, and on
Windows only because Git for Windows ships bash), and the previous PR
had to special-case the Rakefile to invoke bash bin/lint-no-raw-mdc
explicitly.

Change

Rewrote bin/lint-no-raw-mdc as a Ruby script:

  • Shebang is now #!/usr/bin/env ruby
  • Uses Open3.capture3 to invoke git grep
  • Filter logic (excluded paths, comment-line skip) is plain Ruby
  • POSIX ERE source string declared as a constant — git grep -E
    doesn't accept Ruby regex syntax like \d or (?:...)
  • Exit codes preserved: 0 on clean, 1 on violation, 2 on git grep
    internal failure

Rakefile reverted to ruby "bin/lint-no-raw-mdc" — the previous
bash bin/lint-no-raw-mdc workaround is no longer needed. Ruby is
guaranteed on PATH because Rake itself runs on Ruby.

Verified locally

  • bundle exec rake lint:registry — passes on a clean tree
  • Planted "MDC_P999" in a tracked file under lib/opencdd/entity/
    the script reports the violation with exit 1, matching the previous
    bash behavior
  • Clean tree — exit 0

Test plan

  • Local: rake lint passes on main
  • Local: planted violation is detected
  • CI: all 10 jobs green (3.3, 3.4, 4.0 × macOS, Ubuntu, Windows)

TODO files are working notes, not artifacts. They stay local for
reference but should not be committed to the repo. Add TODO* to
.gitignore and untrack TODO.final/ + TODO.impl/. Files remain
on disk for local reference.
This is a Ruby library; the lint script should be Ruby too. The
previous bash version required bash on PATH, and the prior PR had
to special-case the Rakefile with 'bash bin/lint-no-raw-mdc' to
make Windows CI work (cmd.exe cannot dispatch on shebangs).

The Ruby port uses Open3.capture3 to invoke git grep and plain
Ruby for filter logic. POSIX ERE source string declared as a
constant since git grep -E does not accept Ruby regex syntax.
Exit codes preserved: 0 clean, 1 violation, 2 git internal failure.

Rakefile reverted to plain 'ruby bin/lint-no-raw-mdc' - Ruby is
guaranteed on PATH because Rake runs on Ruby.
@ronaldtse
ronaldtse merged commit d9150e1 into main Jul 24, 2026
12 of 13 checks passed
@ronaldtse
ronaldtse deleted the chore/lint-no-raw-mdc-in-ruby branch July 24, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant