Skip to content

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

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

ronaldtse merged 0 commit 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)

@ronaldtse
ronaldtse merged this pull request 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