Skip to content

chore: align json.rs panic msg and document module size budget#49

Merged
Metbcy merged 1 commit into
mainfrom
chore/hygiene-module-budget-expect-msg
May 17, 2026
Merged

chore: align json.rs panic msg and document module size budget#49
Metbcy merged 1 commit into
mainfrom
chore/hygiene-module-budget-expect-msg

Conversation

@Metbcy
Copy link
Copy Markdown
Owner

@Metbcy Metbcy commented May 17, 2026

Small hygiene pass.

Changes

  1. src/render/json.rs:46 — aligned the expect(...) message to the invariant-style wording already used in vex.rs and sarif.rs. Panic audit of src/** (excluding #[cfg(test)] blocks) found only 4 production expects and zero unwraps; 3/4 already had #[allow(clippy::expect_used, reason = ...)] and matching prose — this was the lone outlier.

  2. docs/src/architecture.md — added a "Module size budget" section codifying the implicit convention: soft cap 1000 LOC, hard cap 1500 LOC for src/** (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.

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.
@github-actions
Copy link
Copy Markdown

Coverage report

Line 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; --fail-under-lines will be added once coverage is visible across 2–3 releases.

@Metbcy Metbcy merged commit 2ed658d into main May 17, 2026
10 checks passed
@Metbcy Metbcy deleted the chore/hygiene-module-budget-expect-msg branch May 17, 2026 23:50
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