mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
df7b27c793
Adds a second question about the same tree: not "what is duplicated" but "what does nothing reach". A new `basta` crate builds the import graph from the project's entry points and walks it, reporting unused files, unused exports, unused module-private declarations, unused imports and — opt-in — unused class members, across JavaScript, TypeScript, JSX, TSX and Python. It ships two ways: `jscpd --dead-code` inside the existing binary, and a standalone `basta` command. Both reuse the walker, the filters, all fifteen reporters and the `--threshold` / `--exit-code` gates, so nothing new has to be learned to run it. Because it is a graph traversal rather than a reference count, dead code cascades: a helper whose only caller is itself dead is reported too. Every finding carries a confidence score and, below 100, the reasons it might be wrong — `eval`, an unrecognised decorator, a wildcard re-export, a name seen only in a string, a file in the scan that did not parse. `--min-confidence` sets the floor at 60. Entry points come from `package.json`, `pyproject.toml`, framework and file-name conventions, and anything a shell script, CI workflow, Makefile or Dockerfile names by path. CommonJS is read alongside ESM. A project that renames its own import paths is read on its own terms: `paths` and `baseUrl` from `tsconfig.json` and `jsconfig.json` are resolved, through a relative `extends` chain and per package in a monorepo. A file named only by a path string — a worker spawned through `new URL`, a build entry, a vitest setup file — counts as used. Languages plug in through one trait, `basta::lang::Analyzer`, which owns parsing, specifier resolution, entry-point conventions, manifests, alias configs and path traits. Nothing outside `lang/` is language-specific; `docs/basta-extending.md` walks through adding one. Validated against knip, fallow, vulture, skylos, fossil-mcp and repowise on trending repositories. On a corpus of ten of them — 11k files, 3.3M lines — every one of basta's 1,806 findings was checked against an import graph rebuilt independently of it: no unused-file, unused-import or unused-symbol claim survived as wrong. Claude-Session: https://claude.ai/code/session_01WztdFKZAwW9b51iJe9zhtV
23 lines
426 B
TOML
23 lines
426 B
TOML
[workspace]
|
|
resolver = "2"
|
|
members = [
|
|
"crates/cpd-core",
|
|
"crates/cpd-tokenizer",
|
|
"crates/cpd-finder",
|
|
"crates/cpd-reporter",
|
|
"crates/basta",
|
|
"crates/cpd",
|
|
]
|
|
|
|
[workspace.package]
|
|
edition = "2024"
|
|
rust-version = "1.96"
|
|
authors = ["jscpd contributors"]
|
|
license = "MIT"
|
|
homepage = "https://jscpd.dev"
|
|
repository = "https://github.com/kucherenko/jscpd"
|
|
|
|
[profile.release]
|
|
strip = "symbols"
|
|
panic = "abort"
|