Skip to content

chore: remove dead code and configure knip for every workspace - #1658

Merged
joshunrau merged 16 commits into
DouglasNeuroInformatics:mainfrom
joshunrau:chore/remove-dead-code
Oct 6, 2026
Merged

joshunrau merged 16 commits into
DouglasNeuroInformatics:mainfrom
joshunrau:chore/remove-dead-code

Conversation

@joshunrau

Copy link
Copy Markdown
Collaborator

What changed

knip now covers the whole repo (e6bfff708). Before, knip.ts configured two workspaces, and most of its output was noise: configs failed to load without .env, and the entry points of storybook, the outreach docs, the api's worker thread and test suites, the runtime and the instrument builds were all missing. pnpm knip now loads .env, ignores vendor/, reports unused exports of every internal package (published packages keep their public surface), and marks production entries with ! so knip --production finds code only tests reach. On this branch pnpm knip reports nothing.

Dead code removed, one commit per area (−14.4k lines, about 9.6k of them vim):

  • api: POST /v1/subjects, GET /v1/instrument-repos/:id and GET /v1/sessions/:id, the only routes no first-party client calls (web, playground, gateway, odc-cli and e2e all count as clients). Also service methods only their own tests reached, never-passed params, unused Prisma declarations (no data-bearing fields) and the unserved public/ directory.
  • playground: vim mode, removed entirely, plus components only stories rendered.
  • instrument-library: DNP_STROOP_TASK. No instance loads it, and it never called done.
  • web, gateway, outreach, schemas, react-core, runtime toolchain, small packages, testing, storybook: unused files, exports, translations, props, variants and branches that only their own tests or stories reached, stale config, page-object members, the unused PROJECT_ROOT variable, and unused dependencies, catalog entries, scripts and build permissions.
  • happy-dom is now declared in the three packages whose tests already used it through hoisting.

Kept on purpose:

  • test seams: exports that exist for tests, and injection params like now
  • the public API of published packages, including everything runtime/v1 ships
  • data-bearing Prisma fields
  • the api { ability } param convention
  • web's onBack Back buttons, which are never wired; left for a follow-up
  • vendor/ and instrument-bundler's vendored parse.ts

Worth a look

  • The three removed routes are gone from the OpenAPI spec. External integrations that call them would break. The commits are not marked breaking.
  • Playground users who enabled vim mode keep an inert enableVimMode key in IndexedDB. Nothing reads it.
  • apps/api's Dockerfile drops COPY public (the directory is gone) and the unread GATEWAY_DATABASE_URL. CI only builds images on release.

Found, not fixed

  • The blog index title renders as Open Data Capture - Open Data Capture. blog.title was meant for that slot, so I kept it.
  • apps/playground imports prettier, runtime-bundler imports typescript and runtime-internal's tests use happy-dom, none of them declared. playground-url imports zod at runtime but only has it as a devDependency.
  • knip --production still lists the kept test seams and a few dependencies that belong in devDependencies.

Verification

  • pnpm lint passes.
  • pnpm test:coverage: 381 files, 4309 tests, 100% on all four metrics.
  • pnpm test:e2e: 277 passed.
  • pnpm knip: exits 0 with nothing reported.

This branch only removes code, so it adds no new unit or e2e tests. Tests that covered only the removed code were deleted with it.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

joshunrau and others added 16 commits October 5, 2026 19:15
Knip only covered apps/api and apps/web, and most of what it reported
elsewhere was noise: web's vite config and the playwright config failed
to load without .env, storybook's config dir, astro's docs content, the
api's worker thread and test suites, the runtime config and the
instrument build entries were all invisible to it.

- Load .env and NODE_ENV in the knip script so every config loads.
- Ignore vendor/ and report unused entry exports of every internal
  package; published packages keep their public surface.
- Register the entry points knip's plugins cannot see, and mark the
  production ones with `!` so `knip --production` finds code that only
  tests reach.
- Derive runtime/v1's ignored dependencies from runtime.config.js
  instead of listing them twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the three routes that neither web, playground, the gateway, odc-cli
nor the e2e suite calls: POST /v1/subjects, GET /v1/instrument-repos/:id
and GET /v1/sessions/:id, with the service method only one of them used.

Also remove service methods only their own tests reached
(UsersService.deleteByUsername, InstrumentRecordsService.exists), the
subjectId parameter of GatewayService.fetchRemoteAssignments no caller
passes, the never-passed groupId query on GET /v1/instruments/list, the
optional currentUser on the instrument service methods every caller
already passes it to, the unused InstrumentKind and InstrumentInternal
Prisma declarations, the unserved public/ directory, and exports used
only in their own file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the not-found middleware nothing registers, the subjectId filter
on GET /api/assignments that the API stopped sending, the unused port
parameter of BaseServer.listen, the raw-import esbuild plugin in the dev
script and an unused ImportMeta augmentation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the unreferenced 4.1 instrument example and InstrumentProperties
component, translation keys and namespaces no page reads, props no
caller passes (translationMode, meta author/keywords, the generated
Feature id), the unread testimonial format field, and options of the
typedoc plugin that its only configuration never sets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove translation keys no component reads, the zustand mock no test
loads, the unused analytics config field, props production never passes
(className on LanguageSelect and SectionCard, data-testid on
TimepointTable, subject on the file record view, hideSubmitButton on
UpdateUserForm), the string-key overload of useSearch, the disableRetry
request flag nothing sets, environment guards that never fail in the
browser, and exports used only in their own file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The experimental vim mode was a 9.6k-line port of CodeMirror's vim
bindings whose status bar was never mounted, so its ex commands and
search could not be entered. Remove the port, the editor wiring, the
setting and its dialog field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the ContextMenu, Command and Resizable parts that only stories
render, an example file its instrument never imports, props and options
no caller passes, an always-empty exclusion list, and schemas that were
only ever used as types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- instrument-interpreter: drop the kind option no caller passes; validate
  against $AnyInstrument.
- runtime-bundler: drop the verbose flag and array-of-configs form its
  only config never uses, and package.json checks that cannot fail after
  require.resolve succeeds.
- instrument-bundler: drop the never-set logLevel option and a vitest
  alias pointing at a directory that does not exist.
- runtime/v1: drop tsconfig globs and an eslint ignore that match no
  file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove schemas and types nothing imports, the default instances only the
interpreter's removed kind check used, schemas only their own tests
reached, and the unused /runtime/v1 tsconfig path. Schemas still used to
compose others keep existing but are no longer exported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove SeriesInstrumentContent and ErrorFallback, which only tests and
stories rendered, along with props, variants and branches production
never uses (FileInstrumentContent onSuccess, ErrorBox's message form,
Branding's sm and dark variants, optional ContentPlaceholder message and
null summary items) and a duplicate barrel export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DNP_STROOP_TASK was built but loaded by no instance, and could never
complete because the task never called done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the never-read source field of instrument stubs, the unused
verbose field of serve-instrument's single-mode handler, a duplicate
style build and a stale CLI banner shim from the build scripts, the
number variant of encodeScopedSubjectId and the nullable data default of
extractFieldLabel that only tests used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the subject data table page object no spec reaches, page-object
members no spec calls, pageModels entries no spec navigates to, and two
unused route-param types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the commented-out stories block and the /runtime/v1 tsconfig path
nothing in storybook imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing reads PROJECT_ROOT, and odc-cli's JwtPayload type was never
used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove dependencies no workspace imports, catalog entries nothing
references, scripts that cannot run (storybook in web and react-core,
test:chrome, preview:core) or that nothing runs (inject and its turbo
task), the Bun-only trustedDependencies, build permissions for packages
no longer installed, and react-core's optional router peer and
package.json export.

Declare happy-dom in the three packages whose tests use it, which they
had been resolving through hoisting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshunrau
joshunrau merged commit a857397 into DouglasNeuroInformatics:main Oct 6, 2026
2 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.

1 participant