feat(lint): fence unit conventions with prek hooks#74
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe pull request documents repository unit-handling conventions, adds pre-commit checks for unsafe unit patterns, and annotates workflow configuration values with units and provenance. ChangesUnit safety conventions
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
a3a2c4e to
c4fa3ba
Compare
482d5c8 to
319561a
Compare
319561a to
f0ec9d8
Compare
e62494b to
cd240f4
Compare
cd240f4 to
fa7fbeb
Compare
f0ec9d8 to
9218e28
Compare
Four pygrep fences guard the unit rules established in the preceding changes: no hardcoded speed of light, no G4SystemOfUnits.hh (its unqualified globals collide with the mp-units vocabulary), no CLHEP unit constants outside src/units/, and no hand-typed power-of-ten conversion factors. Verified against pre-migration origin/main: the hooks flag exactly the historical conversion sites. Also documents the conventions in docs/units.md and annotates every dimensional default in workflows/lib.libsonnet with its unit.
fa7fbeb to
64da977
Compare
|
@coderabbitai review |
Physics Metrics Comparison1 configuration(s) have differences
Configurations with Differences
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.pre-commit-config.yaml:
- Around line 31-37: Align the unit-policy checks across all affected sites: in
.pre-commit-config.yaml lines 31-37, remove the blanket src/units/ exclusion and
match G4SystemOfUnits.hh include directives so the ban is repo-wide; in lines
39-44, narrow the CLHEP exception to src/units/clhep_bridge.hpp and detect
forbidden symbol usage rather than only header paths; update docs/units.md lines
39-42 to describe these exact exceptions.
- Around line 23-29: Expand the forbid-hardcoded-c pre-commit hook’s entry
pattern to detect equivalent speed-of-light literals, including scientific
notation such as 2.99792458e8 and 2.99792458E+8 and digit-separated 299'792'458,
while preserving boundary protection against longer unrelated numbers. Add
regression fixtures covering each supported form.
- Around line 46-53: The forbid-magic-unit-factors hook currently misses
plus-exponent notation and block-comment conversion markers. Update its entry
regex to match signed positive exponents such as 1e+3 and conversion indicators
within block comments, while preserving the existing unit-factor and
conversion-context constraints.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4542aa36-6ff0-468e-a748-0422f5c59ed1
📒 Files selected for processing (3)
.pre-commit-config.yamldocs/units.mdworkflows/lib.libsonnet
The prek fences were looser than docs/units.md already claims. Match them up and close notation gaps flagged in review: - forbid-g4-system-of-units: match the #include directive and drop the src/units/ exclusion, so the ban is repo-wide as documented (the bridge's prose mention of the header no longer needs a carve-out). - forbid-clhep-units-outside-bridge: narrow the exception to clhep_bridge.hpp (the only file that needs CLHEP) and also catch CLHEP:: symbol use, not just the include path. - forbid-hardcoded-c: also match scientific-notation (2.99792458e8) and digit-separated forms of the speed of light. - forbid-magic-unit-factors: accept signed-positive exponents (1e+3) and single-line block-comment conversion markers.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Stacked on #73. Four pygrep fences (hardcoded c, G4SystemOfUnits.hh, CLHEP outside the bridge, magic power-of-ten factors — self-tested against pre-migration main), a docs/units.md conventions page, and unit annotations for every dimensional default in lib.libsonnet.
Summary by CodeRabbit
Documentation
Chores