Repository navigation
Daily dead-code sweep 2026-09-29: directions.matrix, TERM_NAMES - #148
EnesYilmazcode wants to merge 3 commits into
Conversation
Both had no caller outside their own declaration and tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GCaTB3nB6X3MkbBCyge5aD
# Conflicts: # sw.js
|
Merged
Verified after merging:
Pushed the merge commit ( Generated by Claude Code |
# Conflicts: # sw.js
Automated daily dead-code sweep. Baseline
node --testonmain(a1ede09): 932 tests, 928 pass, 4 skipped, 0 fail — green, so I fixed nothing and proceeded.Checked against open sweep PRs first (per the routine's rule against re-finding the same code): read the full diffs of #147 (
deadcode/2026-09-27, the#chipsshim), #146 (deadcode/2026-09-24,inBounds), #144 (deadcode/2026-09-23,bestGap/pickGapexport), and #143 (deadcode/2026-09-22,allWeekCodes). Neither finding below overlaps any of those four diffs.Findings, most certain first
1.
directions.matrix()andMATRIX_MAX—js/directions.js(was lines 24, 144-179)What it is:
createDirections()returns an object withsteps(),invalidate(), agenerationgetter, and amatrix()method that batches walking times to many buildings via Google's DistanceMatrixService, gated byMATRIX_MAX = 25.How I proved it dead: this isn't a coverage question, it's a call-graph one.
js/app.jsis the only production caller of the objectcreateDirections()returns (constructed once, atjs/app.js:3590), and I grepped every use ofstate.directionsin it:.invalidate()(line 2077), a truthiness check for the "Step by step" button (lines 2442, 2456), and.steps()(line 2507)..matrixnever appears. I then greppedmatrix(andMATRIX_MAXacrossjs/ scripts/ index.html dev/ spikes/ docs/: the only other hits arescripts/test/directions.test.mjs, which callsd.matrix(...)directly against the module, not through anything the app does. So no user interaction, dev scene, or refusal state can ever reach it — there's no path to it at all, driven or undriven. Since.matrix()is an object method rather than a top-level export,scripts/check-dead-code.mjs(which only walks top-level declarations) can't see it; that's why it reported clean.What would make me wrong: a caller I missed reaching
state.directions.matrixthrough a property access built from a string (e.g.state.directions['ma' + 'trix']) or reflection. I grepped fordirections\[and found nothing, and this codebase's style (plain property access throughout) makes that unlikely.Removed: the
matrix()method,MATRIX_MAX, and the two comment blocks that exist only to explainmatrix()(the "ranking half is opt-in" paragraph in the file header, and the doc comment directly above the method). The paragraph pointed atdocs/research/walking-routes-115.mdfor the underlying design record, which I left untouched — only the code-comment pointer to it, describing the now-removed method, came out. Inscripts/test/directions.test.mjs: removed theMATRIX_MAXimport, theDistanceMatrixServicefake and itscalls.matrixcounter (nothing constructs one anymore), the four matrix-only tests, and the.matrix(...)assertions embedded in two shared tests (without consent,a rejected request) — the.steps()half of each of those already covers the same sharedready()/consent/timeout logic, so no behavior loses coverage.2.
TERM_NAMES—js/state.js:104What it is:
export const TERM_NAMES = { 2: 'Spring', 4: 'Summer', 8: 'Autumn' };, sitting next toROOM_FLOOR(whichfloorFor()does use).How I proved it dead: grepped
TERM_NAMESacross the whole repo. Zero hits anywhere except its own declaration — not injs/app.js, not in any test file, not inscripts/, not inindex.htmlordev/.scripts/build-index.mjshas its own unrelated, unexportedconst TERM_NAMES(a build-time lookup with the same shape, coincidentally the same name) — that's a separate binding in a separate file, not a use of this export. This is a stronger case than the object-method finding above: it isn't even test-exercised, so there's no ambiguity about a code path reaching it under some state I didn't drive. The app gets its term name fromcurrent.termNamedirectly (seeresolveState'scurrent?.termName ?? 'This term'), so this table looks like a leftover from before that.What would make me wrong: nothing I can think of — a zero-reference exported binding either gets used somewhere I didn't grep, or it doesn't exist as a live code path at all.
Runtime coverage attempted, for context
I built a throwaway coverage harness on top of
scripts/lib/browser.mjs/pinned-clock.mjs(never committed) to look for dead CSS selectors and unreachable UI branches, the kind of finding neither grep norcheck-dead-code.mjscan prove alone. Before running it broad, I did a full static pass first: every class/id selector inindex.html's stylesheet, every sprite<symbol>, and every CSS custom property all resolve to at least one real reference injs/*.jsordev/*.html(icons in particular are built as template strings injs/app.js, e.g.WALK_ICON/CHEV, not literal markup, so a naiveindex.html-only grep undercounts them — I checkedjs/*.jstoo). That came back clean, so I did not find a CSS or markup candidate worth driving the full coverage harness to confirm.I also worked out real dates in the shipped
data/rooms-1268.json/data/current.jsonfor each refusal, to know what's actually reachable this term:no-classes(ranks, with a note); 2026-11-26 isoffices-closed→CAMPUS_CLOSED.EXAM_REFUSAL.CAMPUS_CLOSED.roomSearchOn's 7am-11pm weekend window → the unscheduled gate/buildings screen, not one of the six refusalkinds.BETWEEN_TERMS(2026-07-31, before the 08-25 instruction start). The other flavor — "campus is between terms, next term begins X" — needscurrent.next, which the shippeddata/current.jsondoesn't carry yet (no next-term harvest exists), so it's not reachable with real data right now. Left alone, not claimed as dead.SCHEDULE_DARK): I scannedscheduleCoverage()over every date in and around the term. Coverage never drops below the 10%SILENT_SHAREfloor anywhere inside the actual instruction window (2026-08-25 to 2026-12-09) — every date low enough to trip it is also caught by theout-of-termcheck first, which runs earlier inrefusalFor. So this is a defensive branch with no real-data path to it right now, not a live one I failed to drive. Per the rules, not touched.I did not get as far as actually driving the coverage harness through boot/refusal/menu/dev-panel states end to end before concluding the CSS and markup side had nothing to show for it, so I'm not claiming exhaustive runtime proof beyond the two call-graph findings above — those two don't need it (nothing anywhere calls them, driven or not).
Not removed, not proven
Nothing else. I looked at
js/route.js'smetresToPoint/offGraphMetres(same "app has no use for it" shape as the two findings above) but both are genuinely used — the former bydocs/research/walking-graph-sample.mjs, the latter byscripts/test/walk-graph.test.mjs— so I left them alone.Verification
node --test: 928 tests, 924 pass, 4 skipped, 0 fail (4 fewer than baseline — exactly the fourmatrix()-only tests removed).node scripts/check-dead-code.mjs: clean.SHELL_ASSETS) and rannode scripts/stamp-sw.mjs: shell 164,286 → 163,573 bytes, header re-dated 2026-09-29,SHELL_CACHErestamped.node scripts/shoot.mjs --check: passed (one earlier run hit the documentedboot()navigation race and threw; reproduced the same flake against unmodifiedmaintoo, so it's unrelated to this change — a clean re-run confirmed no visual regression).Neither change touches anything reachable from the shipped UI, so no screenshots moved.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GCaTB3nB6X3MkbBCyge5aD
Generated by Claude Code