Skip to content

Drop unreferenced APIs and add a test coverage report - #4

Merged
baairon merged 2 commits into
masterfrom
claude/nifty-thompson-wdnb6c
Oct 6, 2026
Merged

baairon merged 2 commits into
masterfrom
claude/nifty-thompson-wdnb6c

Conversation

@baairon

@baairon baairon commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

This PR does two things:

  1. It removes functions and types that nothing in the app calls anymore.
  2. It adds npm run test:coverage, which shows how much of src the tests actually run.

No user-facing behavior changes.

1. Removing APIs nothing calls

I checked every export in src/ for references in src, test and scripts. Every dependency in package.json and every file under src/ is still in use, so none were removed.

Called from nowhere: useKeybinding, useRegisterKeybindingContext, useOptionalKeybindingContext, RestoreContinuitySnapshotEnvelopeArgs, envelopeChallengeFor, readSkill, readSkillFile (and the private loadSkillBody), PRIVATE_SNAPSHOT_PATHS, sourcesFromFileMap, buildSeedConfigFromStep, buildSeedConfigForIdentity, readValidationFromState, EnsIssueValidation, runPublicProfilePreflight, walletPageFresh, deleteConfig, updateIdentityBackup.

Only their own tests called them (removed along with those tests):

  • encodeApprove and encodeApprovalRevoke. test/identity/ens/resolverDelegation.test.ts only tested these, so it is deleted.
  • identitySummaryRows, tokenCandidateHint, chainSummaryRow, networkLabel, joinWithMore, awaitOptionalReceipt, booleanField, clearIdentity, serializeSkillFile. Where a test also covered live code, it was trimmed instead of deleted. For example, the awaitConfirmedReceipt and networkSubtitle checks are kept.

Some functions are used only by tests but exist to support them, so they stay. Examples: generatePrivateKey, writeDaemonPid, the backup-envelope creators that build restore fixtures, the reset*ForTest helpers, getConfiguredVaultAddress and the Pinata JWT cache helpers.

Imports left unused by these removals are deleted as well. tsc --noEmit --noUnusedLocals passes cleanly.

2. npm run test:coverage

test/run-tests.mjs now takes a --coverage flag. With it, the tests are compiled with source maps and run under Node's built-in coverage, so the report points at the original src files. Plain npm test works the same as before. The new command needs Node 22.5 or later, because older versions don't support the exclude flags it uses.

Coverage today:

  • Files the tests load: 71% of lines, 72% of branches and 76% of functions.
  • Files the tests never load: 56 files in src/, about 6,200 lines not counting type-only files. Node leaves these out of its report entirely. Counting them, real line coverage is about 59%.
  • The browser wallet page (src/identity/wallet/page/) is compiled separately and isn't counted at all.

Where the gaps are: mostly the interactive Ink flows and the effects that send transactions. The CLI entry point and router (main.tsx, IdentityManager.tsx, Routes.tsx) are never loaded. The ENS edit flows, custody and transfer effects, agent reconciliation and restore apply/recovery sit at roughly 12–30%. These paths are live code that tests don't reach, not dead code, so nothing was removed because of the report. Logic like envelopes, sync, config and the network layer is mostly 80–100% covered.

Verification

  • npm run typecheck: passes.
  • npm test: 710 pass and 9 fail. On master in the same container it is 723 pass and the same 9 fail. The 13 fewer passes are the 13 tests removed in this PR. The 9 failures are all color-styling tests in wrapSafety and they fail identically on master.
  • npm run test:coverage: gives the same results and prints the report.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GjuD2e7tgdWWdpmUMkcZcS

claude added 2 commits October 6, 2026 22:04
Delete exported functions, types and constants that nothing in the
codebase calls, plus the imports and private helpers left orphaned by
those removals. Functions that only tests still reached are removed
together with their tests; test seams and fixture builders stay.

Dependencies and files were also checked: every package and every file
under src is still in use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GjuD2e7tgdWWdpmUMkcZcS
Compiles the tests with source maps and runs them under Node's built-in
coverage, so the report points at the original src files. Test and
node_modules files are excluded from the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GjuD2e7tgdWWdpmUMkcZcS
@baairon baairon changed the title Remove dead code from src and the tests that only covered it Drop unreferenced APIs and add a test coverage report Oct 6, 2026
@baairon
baairon merged commit 31d4a0a into master Oct 6, 2026
3 checks passed
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