Skip to content

Daily dead-code sweep 2026-10-12: createWatch's unused id/open getters - #178

Open
EnesYilmazcode wants to merge 1 commit into
mainfrom
deadcode/2026-10-12
Open

EnesYilmazcode wants to merge 1 commit into
mainfrom
deadcode/2026-10-12

Conversation

@EnesYilmazcode

Copy link
Copy Markdown
Owner

Automated run of the daily dead-code sweep routine.

Checked against open sweep PRs first

8 earlier sweep PRs are open and unmerged, all branched from main before this one: #176, #175, #169, #148, #147, #146, #144, #143. I fetched and read every diff before sweeping, so nothing below duplicates them:

My own runtime coverage run independently re-derived most of these same functions as uncovered (inBounds, bestGap, inScheduledHours, allWeekCodes, get generation, matrix, and the attachGestures teardown closure all showed zero call count), which is a second, independent confirmation of those PRs' claims. None of that is repeated here.

What this PR removes

js/state.js, createWatch's get id() / get open() (2 getters, ~3 lines).

Proof: node --test baseline was green (938 tests, 934 pass, 4 skipped, 0 fail). I then drove the real app with a Chrome-over-DevTools-Protocol harness (reusing scripts/lib/browser.mjs and scripts/lib/pinned-clock.mjs, the same way scripts/shoot.mjs does) with Profiler.startPreciseCoverage({callCount:true, detailed:true}) running continuously, and drove every geolocation-touching path I could reach in one continuous session plus several cold reloads:

  • the question screen, duration pick, card, swipe-left/right, the way screen, the ranked list (binning the whole deck), a selected room, the room's day calendar with both day-nav arrows walked past the term's own start and end
  • the menu, browse buildings (search, open a building, open a room from it), the building picker, "What Vacant knows"
  • the gate card reached cold from the ask screen on a weekday evening (outside scheduled hours) with the gate's "Show nearest buildings" button actually pressed, landing on real nearest-building data
  • every dev-panel jump date: Wed 4:10pm, Wed 10:30pm (weekday evening, outside hours), Fri 7:30pm, Sat 3am, Sun noon, Labor Day (campus closed), Autumn Break (no-classes), Thanksgiving Day (offices closed), finals week (the real exam window, 2026-12-11–2026-12-17, from data/rooms-1268.json), the gap between teaching-end and exams, winter break, and a far-future date with no term data at all
  • ?dev=1, /dev/, and /dev/warp.html
  • an offline reload (service-worker cache) and two distinct boot-failure states: the fully-cold firstrun "cold" card (no cache, blocked fetch) and bootFailed's own gate card (warm shell cache, this reload's data fetch blocked) — these are two different code paths and I confirmed both independently

0 page errors across the whole run. watch.id / watch.open never fired in any of it. js/app.js only ever calls watch.start(...) and watch.stop() on the object createWatch returns — grepping js/, scripts/, index.html, dev/, spikes/, docs/ for watch.id/watch.open/w.id/w.open/bare.open/thrower.open turns up nothing outside scripts/test/follow.test.mjs, which is the module's only caller of either getter.

scripts/test/follow.test.mjs is rewritten, not weakened: every assertion that used to read .id/.open directly now proves the identical fact through start()/stop()'s own return values, which the file's 26-mutation review already relies on elsewhere in the same suite:

  • "the handle it clears is the handle it opened" — w.id === 7 was fully redundant with the very next line (geo.calls.clear deep-equals [7], which already requires the real handle to have flowed through); just dropped.
  • "stopping drops the handle" — w.open === false was redundant with the following w.start(gps) === 'open' (a stuck handle would return 'already-open'); dropped.
  • "a throw inside clearWatch still drops the handle" — had no follow-up check, so I added one: w.start(gps) === 'open' right after the failed stop(), which only passes if the throw still cleared the handle.
  • "an unsupported or throwing geolocation leaves no handle behind" — same pattern: bare.open === false replaced with bare.stop() === 'closed' (which stop() only returns when the handle is already null); thrower.open === false was redundant with the test's own closing thrower.stop() === 'closed', so it's dropped and its documentation message moved onto that line.

node --test is green after the edit (938 tests, 934 pass, 4 skipped, 0 fail — identical to baseline), node scripts/check-dead-code.mjs reports clean before and after, and the sw.js gzip-figure test still passes (the ~3 line removal from js/state.js, part of the shell cache, moved the actual gzipped shell size by far less than the test's 1% tolerance, so no stamp-sw.mjs re-run was needed). Nothing here touches index.html or anything scripts/shoot.mjs photographs, so I didn't need to re-run it.

Not removed, not proven

Everything below showed up as "never called" in the same coverage run, but I could not drive the state that would call it, so I'm leaving it alone rather than guessing:

  • Google-Maps-consent-gated walking directions (directions.js's plainText, loadMaps, withTimeout, ready, steps; app.js's askSteps and its consent checkbox) — needs a real Google Maps API key and state.googleConsent === true, which this sandbox has neither the credentials nor the network policy to provide.
  • The "Add to Home Screen" banner (all of js/install.js) — needs a real beforeinstallprompt event, which headless Chrome doesn't fire.
  • Map pan, pinch-zoom, and wheel-zoom (map.js's panBy, zoomBy, drawPin, wheel, the pinch spread helper) — I never panned, pinched, or wheel-zoomed the map; only tapped it.
  • The relaxation ladder's weaker rungs (engine.js's any-type, opens-at, further, anywhere, longest rungs and state.js's rungPhrase, the sentence that explains a relaxed answer) — my one pinned scenario (a 2-hour ask, Wednesday 10:20am) always had hundreds of rooms satisfying the top rung, so the ladder never had to relax, and the explanatory sentence for a relaxed answer never had anything to describe.
  • The zero-result ranked answer (app.js's emptyAnswer) — same reason; I never asked a question with zero rooms free.
  • The room photo canvas (drawContained) and the picker's own embedded map (pickMapPoint, commitPickedOrigin, clearPickedOrigin, the pick-screen's onPan/onZoom/onTap) — I used a direct pick-row tap rather than the picker's map or a room with a working photo.
  • The service-worker update banner (pwa.js's showRefresh, reloadOnce, the vacant:data-updated message handler) — needs a real new-SW-version postMessage.
  • firstrun.js's "Check again" retry button — I reached the fully-cold card but never pressed it.
  • SCHEDULE_DARK — I drove every date between the committed calendar's teaching start and well past its exam window, including the exact gap between teaching-end and exams; every one of them resolved to BETWEEN_TERMS/TERM_ENDED, never SCHEDULE_DARK. This matches scripts/test/screens.test.mjs's own comment that no date on the shipped calendar can reach it any more — consistent, not a new finding.
  • CSS rule coverage — I started CSS.startRuleUsageTracking() as planned, but index.html, js/dev.js, js/firstrun.js, js/pwa.js, and js/install.js each inject their own <style> block, and my dedup keyed purely on byte offset collided across those different stylesheets. I'm not confident in the result, so I'm not claiming any CSS selector as dead this run.

Clock run

node --test: 938 tests, 934 pass, 4 skipped, 0 fail (unchanged by this PR).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bb1exFqRPbNmgJubUTp74U


Generated by Claude Code

Full runtime coverage across every geolocation state (locate, watch
start/stop, follow, every onFix/onError path, offline, dev mode) never
reads watch.id or watch.open; js/app.js only ever calls .start()/.stop().
Both getters are exercised solely by scripts/test/follow.test.mjs, which
is rewritten here to verify the same behavior through start()/stop()
return values instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb1exFqRPbNmgJubUTp74U

This branch has not been deployed

No deployments
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.

2 participants