Skip to content

Dead-code sweep: unreferenced exports, orphaned modules, unused deps, commented-out blocks #2821

Description

@thedavidmeister

Ask

Sweep the whole repo for dead code — unreferenced exports, orphaned modules, unused dependencies, and commented-out blocks — and either wire each finding up or delete it.

Why now

Triaging the issue backlog surfaced a steady drip of these, each found incidentally while verifying something else. They are not hypothetical:

  • successMessage is dead. packages/ui-components/src/lib/providers/transactions/TransactionManager.ts:489-491 defines const successMessage = "Order deployed successfully.", but createTransaction wires only errorMessage; TransactionStore's constructor never reads it. A repo-wide search for "deployed successfully" returns the definition plus two test files — it never reaches the DOM. It reads like working configuration and isn't, which is how a reviewer ends up believing success toasts exist. (Found while closing nothing visual happens in the app when an order is successfully deployed #523.)
  • OrderAPY.svelte and VaultBalanceChart.svelte are 100% commented out, and VaultBalanceChart was removed from VaultDetail. Their presence was cited as evidence that a refactor had landed, when the code cannot run at all. (Found while re-opening Refactor front-end caching and pagination of list queries to support chart data #229.)
  • @codemirror/lang-yaml 6.1.1 is a declared dependency of packages/ui-components with zero importers on main — it belonged to the deleted CodeMirrorConfigSource.svelte.
  • CodeMirrorRainlang.svelte's editable path (codeMirrorDisabled={false} + onSave) has tests but no production caller — only the read-only path is mounted.
  • Conversely, @codemirror/lint and @lezer/highlight are imported but not declared as dependencies of packages/ui-components — they resolve only transitively, so a hoisting change breaks them. Same sweep, opposite direction.

Guardrail: orphaned ≠ dead

Some unreferenced code is deliberately parked and must not be deleted. #2820 (restore in-app order authoring) depends on exactly this kind of code:

  • packages/ui-components/src/lib/components/CodeMirrorDotrain.svelte — exported, tested, mounted by nothing.
  • crates/common/src/dotrain_add_order_lsp.rs — compiles, has tests, no caller anywhere in the repo.

A naive "delete what nothing references" pass would remove the pieces we just decided to bring back. So the deliverable is a triaged list with a disposition per finding (wire up / delete / keep-with-reason), not an automated deletion PR. Anything kept deliberately should say so in a comment, so the next sweep doesn't re-litigate it.

Suggested approach

Rust (crates/)cargo +nightly udeps or cargo machete for unused dependencies; #[deny(dead_code)] in a scratch build to enumerate unreferenced items; grep for pub items with no in-repo caller (the DotrainAddOrderLsp shape: declared in lib.rs, never called). Note wasm-gated code needs care — an item can be live for one target and dead for another (problems() is #[cfg(not(target_family = "wasm"))]).

TS/Svelte (packages/)knip (handles unused files, exports and deps in one pass, understands Svelte) or ts-prune + depcheck; check both directions on dependencies (declared-but-unused and imported-but-undeclared). Barrel files (lib/index.ts) will mask orphans — an export from a barrel that nothing outside the barrel imports is still dead.

Commented-out code — treat any wholly-commented file or block as a finding: reinstate or delete, don't leave it.

Consider a CI gate for the mechanical parts (unused deps, undeclared imports) once the backlog is cleared, so this doesn't re-accumulate.

Scope note

Whole-repo, all languages — crates/*, packages/* (raindex, ui-components, webapp), and the workflow/script layer. Excludes generated artifacts and vendored code.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions