feat: add dead code analysis tooling#194
Conversation
|
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
ac07ff2 to
94471d2
Compare
Greptile SummaryThis PR adds dead code and dependency analysis tooling to the monorepo using rev-dep (per-package import graph / boundary enforcement) and Knip (cross-package dead code tracing). Two new scripts — Issues found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[pnpm analyze / pnpm analyze:select] --> B[Run rev-dep config run]
A --> C[Run knip per workspace]
B --> D[Parse rev-dep text output]
D --> D1[circularDeps]
D --> D2[orphanFiles]
D --> D3[restrictedImports]
D --> D4[unresolvedImports]
D --> D5[unusedExports ⚠️ never rendered]
D --> D6[restrictedDevDeps]
C --> E[Parse knip JSON output]
E --> E1[unusedFiles]
E --> E2[unusedDeps / unusedDevDeps]
E --> E3[unusedExports / unusedTypes]
E --> E4[duplicateExports]
D1 & D3 & D4 & D6 --> F[Section 1: Architecture]
E1 & E3 & E4 --> G[Section 2: Dead Code]
D2 --> H[Section 3: Orphan Files]
E2 --> I[Section 4: Dependencies]
F & G & H & I --> J[Unified Color-coded Report + Issue Count]
style D5 fill:#ffcccc,stroke:#cc0000
|
33c2781 to
59a53be
Compare
|
@claude review |
cameronapak
left a comment
There was a problem hiding this comment.
I like what you've done and have seen your demo. This combo of these tools seems like it'll be really helpful. Please await Claude's review to see what it says. Thank you for this, Jared!
|
@claude review |
|
I'm not sure if Claude's going to review this one haha. If another hour goes by and Claude hasn't done anything, then please feel free to merge this one in. |
Add dead code & dependency analysis tooling
Summary
Adds automated dead code detection, dependency auditing, and package boundary enforcement to the monorepo using two complementary tools: rev-dep (per-package import graph analysis) and Knip (cross-package dead code tracing).
Motivation
As the SDK grows, it becomes easy for exports, files, and dependencies to go unused without anyone noticing. Boundary violations (e.g.,
coreaccidentally importing React) can also slip through in review. This PR introduces tooling to catch these issues automatically.What's Included
New scripts
pnpm analyzepnpm analyze:selectNew files
.rev-dep.config.jsonc— rev-dep configuration with rules for all 5 workspace targets (core, hooks, ui, eslint-config, tsconfig). Enforces thecore → hooks → uidependency graph and prevents reverse imports.scripts/analyze.mjs— Runs both tools across all packages and merges results into a single grouped report (Architecture, Dead Code, Orphan Files, Dependencies).scripts/analyze-select.mjs— Interactive multi-select menu for scoped analysis. Supports selecting any combination of packages/tools.docs/dead-code-analysis.md— Full documentation on usage, configuration, and how to read the report.New dependency
rev-dep@^2.11.0(devDependency) — Import graph analyzer with boundary enforcement and circular dependency detection.Package.json changes
analyze,analyze:selectscripts +rev-depdevDependencyWhat the tools detect
Why two tools?
Boundary enforcement
The rev-dep config enforces the monorepo's dependency direction:
corecannot importreact,react-dom, hooks, or uihookscannot import uiuihas no restrictions (top of the stack)Testing
pnpm analyzeto verify the tools work end-to-end