chore: drop an unused dirs declaration, reject the cargo-machete gate - #287
Merged
Conversation
Cycle 18 recommended wiring cargo-machete to automate the unused-declared-dependency class. Running it first disqualified it, and turned up one real finding. `cargo machete` reports six findings on this workspace. One is real: `codelore-cli` declares `dirs` and never calls it -- all three mentions in its sources are comments about `codelore-lib`'s cache-root resolution, and the single real `dirs::cache_dir()` call lives in `codelore-lib/src/cache.rs` beside that crate's own declaration. That declaration is removed here, verified by deleting it and building rather than by searching for the name -- which is exactly what would have gone wrong, since the name does appear in the crate's text. The other five name load-bearing code: - `num-traits`, required via `#[derive(FromPrimitive)]` expansion in six generated files; removing it fails with E0463. - `tree-sitter-java`, `-javascript`, `-python`, `-rust` -- four of the five grammars the product actually dispatches. Acting on that output deletes those languages. The tool's own output proves the mechanism. `tree-sitter-typescript` is the only grammar it does NOT flag, and the only one named outside the `mk_langs!` invocation -- it appears directly in the `get_language!` special case in macros.rs. Four grammars named only inside the macro get flagged; the one named outside is clean. cargo-machete is a text scanner and macro invocations are opaque to it; cargo-shear concedes the same limit, liftable only with a nightly --expand. Reaching green would take five ignore entries, at which point the gate suppresses more than it reports and each entry is a standing invitation to remove the wrong one. That also fails the bar this repo set when it adopted zizmor: an advisory version was written and discarded because a check that is red for the wrong reason teaches people to ignore red checks. Recorded as a struck-through Tier 2 row rather than under "Deliberately out of scope" -- that section is for product-scope exclusions surfaced from competitive and literature audits, and this is a tooling evaluation. It matches the shape of the closed petgraph row directly beneath it. Verified: fmt --check clean; `cargo check -p codelore --all-targets --all-features` clean with the declaration removed. The full workspace gate could not complete locally -- libduckdb-sys hit ENOSPC (errno 28) on a host at 100% disk -- so CI carries that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cycle 18 recommended wiring
cargo-macheteto automate the unused-declared-dependency class. Running it first disqualified it — and turned up one real finding, which this PR fixes.The measurement
cargo machetereports six findings on this workspace. One is real.dirs(cli)num-traits(rca)#[derive(FromPrimitive)]expansion; removing it fails withE0463tree-sitter-javamk_langs!— a grammar the product dispatchestree-sitter-javascripttree-sitter-pythontree-sitter-rustFour of the five working grammars are reported as removable. Acting on that output deletes Java, JavaScript, Python and Rust support.
The mechanism, proved by the tool's own output
tree-sitter-typescriptis the only grammar it does not flag — and the only one named outside the macro, appearing directly in theget_language!special case inmacros.rs. Four grammars named only insidemk_langs!: flagged. One named outside: clean.cargo-macheteis a text scanner and macro invocations are opaque to it.cargo-shearconcedes the same limit, liftable only with a nightly--expand.This also sharpens what #278's CHANGELOG said. That entry noted unused-dependency tooling "would not have found" the unreachable grammars. The more dangerous fact is that it actively reports the working ones as removable.
Why rejected rather than deferred
"Deferred" implies waiting on something; nothing is pending. Reaching green would take five ignore entries, at which point the gate suppresses more than it reports and each entry is a standing invitation to remove the wrong one.
It also fails the bar this repo set when adopting
zizmor: an advisory version was written and discarded because "a check that is red on every pull request teaches people to ignore red checks."The class is still worth catching. The method that works is the one that found all of this: remove the declaration and build.
The real finding
codelore-clideclaresdirsand never calls it. All three mentions in its sources are comments aboutcodelore-lib's cache-root resolution; the single realdirs::cache_dir()lives incodelore-lib/src/cache.rs:133beside that crate's own declaration.Verified by deleting the declaration and building — which matters here, because the name does appear in the crate's text. A grep says "used"; the build says otherwise. That is the mirror image of
num-traits, which appears zero times and is required.Placement
Recorded as a struck-through Tier 2 row, not under "Deliberately out of scope" — that section is for product-scope exclusions surfaced from competitive and literature audits, and this is a tooling evaluation. It matches the closed
petgraphrow directly beneath it.Verification
cargo fmt --all --check— cleancargo check -p codelore --all-targets --all-features— clean with the declaration removedlibduckdb-syshit ENOSPC (errno 28) on a host at 100% disk (92G shared cargo cache). CI carries that verification.