Skip to content

cleanup: remove dead code, unreferenced barrels, and unused/unlisted deps - #209

Open
5PK wants to merge 2 commits into
mainfrom
cleanup/dead-code
Open

cleanup: remove dead code, unreferenced barrels, and unused/unlisted deps#209
5PK wants to merge 2 commits into
mainfrom
cleanup/dead-code

Conversation

@5PK

@5PK 5PK commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Dead-code cleanup, audited with knip (unused files/exports/dependencies) plus manual grep verification for anything only referenced by its own test file (knip's default settings don't catch that). Holding a fourth category — ~74 unused exports that cascade through still-live barrel index.ts re-exports (e.g. lib/shared/index.ts, lib/workflows/index.ts) — for a separate pass, since trimming individual exports out of a barrel that's genuinely imported elsewhere is a different, higher-touch kind of change than deleting a standalone dead file.

Depends on #208 (PROD-2446) — this branches off fix/PROD-2446, not yet merged, so this diff includes that PR's commit until it lands. The actual new work here is the final cleanup: commit.

Dead files/classes removed

Each confirmed via grep to have zero importers besides its own test file:

  • ContentClassifier (content-classifier.ts) — superseded by getContentItemTypes, never wired into the live push flow
  • LinkTypeDetector (link-type-detector.ts) — never imported anywhere
  • areContentDependenciesResolved (are-content-dependencies-resolved.ts) and its sole dependency, the boolean hasUnresolvedContentReferences in has-unresolved-content-references.tscollectUnresolvedContentReferences, which is used (by the PROD-2309 guard), is untouched
  • core.content class (core/content.ts) — its only method, updateContentItems(), guesses a container's cache path via a camelize() transform that doesn't match how any downloader actually stores containers (by contentViewID); not called anywhere in the CLI
  • types/comparisonResult.ts — an empty {[key:string]:any} interface; types/index.ts already had a comment noting it exports nothing

Unreferenced barrel index.ts files removed

Zero internal importers, and per .npmignore only dist/index.js ships (not src/), so these can't be reaching external library consumers either — unlike core/index.ts, which src/index.ts genuinely imports from:

  • lib/downloaders/index.ts, lib/getters/filesystem/index.ts, lib/pushers/index.ts (which also had a literal duplicate content-pusher re-export line), lib/ui/console/index.ts, lib/ui/progress/index.ts

Removed the now-dangling re-export lines for the deleted files from lib/content/index.ts, lib/shared/index.ts, and core/index.ts.

package.json

  • Dropped 10 unused runtime deps + 1 unused devDependency, each verified with a grep for a real import/require (a couple of knip's matches were coincidental substring hits — e.g. "ora" inside "restore"; one dependency, blessed, has an explicit // Remove blessed case - no longer supported comment already in the code).
  • Added 4 deps that were imported but never declared: proper-lockfile, dotenv, lodash, axios — previously working only because some other package's transitive install happened to provide them.
  • package-lock.json/yarn.lock regenerated to match.

Testing

  • Full suite: npm test — 101 suites / 1834 tests passing (down from 105/1924, matching the removed dead tests — no other regressions).
  • npm run build — compiles clean.
  • Re-ran knip after the cleanup: the "Unused files" / "Unused dependencies" / "Unlisted dependencies" / "Unused devDependencies" sections are all now empty; only the held-back "Unused exports" (Tier 4) category remains.

🤖 Generated with Claude Code

5PK and others added 2 commits August 27, 2026 09:37
PROD-2431/2435/2442 fixed ContentFieldMapper's remap of a linked-content
field's companion column (LinkeContentDropdownValueField/SortIDFieldName),
but two sibling utilities that scan the same content-item field data for
different purposes were never updated to match — both still assumed a
reference is only ever shaped as a contentid/contentID/sortids object key,
with no knowledge of an arbitrarily-named companion field.

1. has-unresolved-content-references.ts (the PROD-2309 pre-push guard):
   collectUnresolvedContentReferences() now takes the source model and also
   checks each Content field's companion column. Previously an unresolved
   reference living only in a companion field shipped to the target
   undetected — the field mapper leaves it as the SOURCE id and only warns
   (not errors), which content-batch-processor.ts doesn't log or block on —
   reproducing the exact opaque server NullReferenceException PROD-2309
   was built to prevent.

2. collect-content-id-references.ts (push-order dependency detection):
   collectContentIDReferences() now takes the source model too, so an item
   referenced only through a companion field is recognized as a dependency
   and promoted to push first (get-content-item-types.ts resolves each
   item's own source model via modelMapper to supply it).

Extracted the companion-field-pair lookup (previously private inside
ContentFieldMapper) into a shared src/lib/content/linked-content-companion-fields.ts
(getLinkedContentCompanionFields/findFieldKey), used by all three now
instead of duplicating the logic a third time.

Added regression tests for both utilities (arbitrarily-named companion,
SortIDFieldName companion, case-insensitive match, sentinel/no-model
back-compat) plus a get-content-item-types push-order test proving an
item referenced only via a companion field gets promoted to linked.

Full suite: 105 suites / 1924 tests passing. npm run build compiles clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…deps

Audit (knip + manual grep verification) for exports/files with zero
consumers outside their own tests. Holding a fourth category (~74 unused
exports cascading through still-live barrel index.ts re-exports, e.g.
lib/shared/index.ts, lib/workflows/index.ts) for a separate pass — riskier
to trim piecemeal than deleting standalone dead files.

Dead files/classes removed (each confirmed to have no importer besides its
own test file):
- ContentClassifier (content-classifier.ts) — superseded by
  getContentItemTypes, never wired into the live push flow
- LinkTypeDetector (link-type-detector.ts) — never imported anywhere
- areContentDependenciesResolved (are-content-dependencies-resolved.ts) and
  its sole dependency hasUnresolvedContentReferences (the boolean variant
  in has-unresolved-content-references.ts) — collectUnresolvedContentReferences,
  which IS used, is untouched
- core.content class (core/content.ts) — updateContentItems()'s container
  lookup guesses a cache path via a camelize() transform that doesn't match
  how any downloader actually stores containers (by contentViewID); not
  called anywhere in the CLI
- types/comparisonResult.ts — an empty {[key:string]:any} interface;
  types/index.ts already had a comment noting it exports nothing

Unreferenced barrel index.ts files removed (zero internal importers, and
per .npmignore only dist/index.js ships — not src/ — so they can't be
reaching external library consumers either, unlike core/index.ts which
src/index.ts genuinely imports from):
- lib/downloaders/index.ts, lib/getters/filesystem/index.ts,
  lib/pushers/index.ts (which also had a literal duplicate
  content-pusher re-export line), lib/ui/console/index.ts,
  lib/ui/progress/index.ts

Removed the now-dangling re-export lines for deleted files from
lib/content/index.ts, lib/shared/index.ts, and core/index.ts.

package.json: dropped 10 unused runtime deps + 1 unused devDependency
(each verified via grep to have no real import — a couple of knip's
matches were coincidental substring hits, e.g. "ora" inside "restore";
one has an explicit "Remove blessed case - no longer supported" comment
already in the code). Added 4 deps that were imported but never declared
(proper-lockfile, dotenv, lodash, axios) — previously working only via
some other package's transitive install. package-lock.json/yarn.lock
regenerated to match.

Full suite: 101 suites / 1834 tests passing (down from 105/1924, matching
the removed dead tests). npm run build compiles clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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