Skip to content

Add large-file ratchet + duplicate-code guardrails (CI + pre-commit) - #174

Merged
important-new merged 1 commit into
InspectorHub:mainfrom
important-new:chore/refactor-guardrails
Jun 21, 2026
Merged

Add large-file ratchet + duplicate-code guardrails (CI + pre-commit)#174
important-new merged 1 commit into
InspectorHub:mainfrom
important-new:chore/refactor-guardrails

Conversation

@important-new

Copy link
Copy Markdown
Contributor

Add large-file ratchet + duplicate-code guardrails

Prevents the monoliths just split (inspection.service / inspections / admin /
inspection-edit, etc.) from growing back, and stops copy/paste from creeping in —
enforced locally (pre-commit) and in CI (npm run lint).

Large-file ratchet — scripts/check-file-size.mjs + file-size-baseline.json

  • Limit 400 lines for hand-written source (generated + tests excluded).
  • A new file over the limit fails; the 43 currently-oversized files are
    grandfathered in the baseline, capped at their current size, and may only
    shrink (--update tightens the ratchet). Bumping the baseline is a deliberate,
    reviewed escape hatch — same philosophy as db:check's KNOWN_ACCEPTED and the
    bundle-size cap.

Duplicate-code ceiling — jscpd (.jscpd.json, threshold 5%)

  • Current duplication 4.2%; the gate fails if it climbs past 5%.

Wiring

Both are in npm run lint (so CI's verify job enforces them with no workflow
change) and added as steps in .githooks/pre-commit. Verified: gates pass on
current code, catch a synthetic 401-line file (fail), and the commit's full
pre-commit (type-check + both gates + bundle) is green.

🤖 Generated with Claude Code

Prevent the monoliths just split from growing back, and stop copy/paste from
creeping in:
- scripts/check-file-size.mjs + file-size-baseline.json: ratchet gate (limit 400
  lines). New oversized files fail; the 43 grandfathered files are capped at
  their current size and may only shrink (--update tightens the ratchet). Excludes
  generated + tests.
- jscpd (.jscpd.json, threshold 5%, current 4.2%): duplicate-code ceiling.
- Wired both into npm run lint (CI) + the pre-commit hook, alongside the existing
  ds/migrefs scans.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014mPDZXfG1msCexx1sL7zyP
@important-new
important-new merged commit 7788a2c into InspectorHub:main Jun 21, 2026
4 checks passed
@important-new
important-new deleted the chore/refactor-guardrails branch June 21, 2026 03:04
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