chore: align json.rs panic msg and document module size budget#49
Merged
Conversation
Two small hygiene items surfaced during a panic-audit pass over
src/.
1. src/render/json.rs:46 used a terse '.expect("serialize JSON")'
while the equivalent invariant in src/vex.rs and src/render/sarif.rs
uses the self-documenting form ('invariant: serde_json::to_string_pretty
cannot fail on a Value built from owned data with string keys').
The terse message is misleading on a panic — a reader would think
serialization actually failed, when the panic is a should-never-happen
guard on a structurally-validated input. Align the message so all
three call sites read the same way.
Verified: 'cargo test --lib render::json' still green (5/5).
2. docs/src/architecture.md gains a 'Module size budget' section
mirroring the existing 'Binary size budget' pattern:
- Soft cap: ≤ 1000 LOC per src/*.rs (incl. embedded test mod)
- Hard cap: ≤ 1500 LOC (split before adding behavior)
- Audit command + waiver path
PR #44 (markdown.rs split) sets the reference shape. Current
offenders (vex.rs 1441, run.rs 1326, render/sarif.rs 1205,
enrich/typosquat.rs 1088, baseline.rs 1072) are now greppable
candidates for follow-up refactor PRs; #31 is the next one in
the pipeline.
No production code paths change in this commit.
Coverage reportLine coverage: 84.1% (9382 / 11150 lines) Full lcov report available as workflow artifact coverage-lcov: download from this run. v0.9.8 introduces this report; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small hygiene pass.
Changes
src/render/json.rs:46— aligned theexpect(...)message to the invariant-style wording already used invex.rsandsarif.rs. Panic audit ofsrc/**(excluding#[cfg(test)]blocks) found only 4 productionexpects and zerounwraps; 3/4 already had#[allow(clippy::expect_used, reason = ...)]and matching prose — this was the lone outlier.docs/src/architecture.md— added a "Module size budget" section codifying the implicit convention: soft cap 1000 LOC, hard cap 1500 LOC forsrc/**(tests exempt), with PR chore(render): split markdown renderer into modules #44 referenced as the split exemplar.Verification
cargo test --lib render::json— 5/5 pass.