feat(deps): use cargo machete --with-metadata and remove unused dev-deps#1809
Conversation
…eps (torrust#1804) Switch pre-commit hook to use `cargo machete --with-metadata` for stricter, metadata-accurate unused-dependency detection. Remove unused dev-dependencies found by the stricter check across 13 Cargo.toml files: - Cargo.toml (root): local-ip-address, mockall - packages/swarm-coordination-registry: async-std, criterion, rand, torrust-tracker-test-helpers - packages/server-lib: rstest (section removed) - packages/udp-tracker-core: torrust-tracker-test-helpers - packages/axum-rest-tracker-api-server: local-ip-address, mockall - packages/udp-tracker-server: local-ip-address - packages/primitives: rstest (section removed) - packages/tracker-core: local-ip-address, torrust-rest-tracker-api-client - packages/peer-id: pretty_assertions (section removed) - packages/torrent-repository-benchmarking: async-std - packages/axum-http-tracker-server: torrust-tracker-events, zerocopy; keep serde_bytes (false-positive) with cargo-machete ignore metadata - packages/axum-health-check-api-server: tracing-subscriber - packages/http-tracker-core: formatjson, serde_json Verified: cargo machete --with-metadata clean, cargo build --workspace clean, cargo test --workspace all pass, linter all exit 0.
e5e7f51 to
ec462dd
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates dependency hygiene tooling to use cargo machete --with-metadata (more accurate dependency detection) and removes now-identified unused dev-dependencies across the workspace, with documentation updated to reflect completion of issue #1804.
Changes:
- Switch pre-commit dependency check to
cargo machete --with-metadata. - Remove unused dev-dependencies across multiple workspace crates.
- Add a
cargo-macheteignore for a known false-positive (serde_bytes) and update the tracking issue doc.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contrib/dev-tools/git/hooks/pre-commit.sh | Run cargo machete with --with-metadata in pre-commit. |
| Cargo.toml | Remove unused workspace-level dev-dependencies. |
| packages/axum-health-check-api-server/Cargo.toml | Remove unused tracing-subscriber dev-dependency. |
| packages/axum-http-tracker-server/Cargo.toml | Remove unused deps and add cargo-machete ignore metadata for serde_bytes. |
| packages/axum-rest-tracker-api-server/Cargo.toml | Remove unused dev-dependencies. |
| packages/http-tracker-core/Cargo.toml | Remove unused dev-dependencies used for tests/formatting. |
| packages/peer-id/Cargo.toml | Remove dev-dependencies section (unused). |
| packages/primitives/Cargo.toml | Remove dev-dependencies section (unused). |
| packages/server-lib/Cargo.toml | Remove dev-dependencies section (unused). |
| packages/swarm-coordination-registry/Cargo.toml | Remove multiple unused dev-dependencies. |
| packages/torrent-repository-benchmarking/Cargo.toml | Remove unused async runtime dev-dependency. |
| packages/tracker-core/Cargo.toml | Remove unused dev-dependencies. |
| packages/udp-tracker-core/Cargo.toml | Remove unused test-helper dev-dependency. |
| packages/udp-tracker-server/Cargo.toml | Remove unused dev-dependency. |
| docs/issues/open/1804-use-cargo-machete-with-metadata-and-remove-unused-dev-deps.md | Mark issue as implemented and record verification evidence/PR linkage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
ACK 7aa49ef |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1809 +/- ##
========================================
Coverage 77.70% 77.70%
========================================
Files 379 379
Lines 28607 28607
Branches 28607 28607
========================================
Hits 22228 22228
+ Misses 6071 6066 -5
- Partials 308 313 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Fixes #1804.
Plain
cargo macheteuses text-scan which produces false negatives for dev-dependencies.Switching to
cargo machete --with-metadata(which usescargo metadatafor accuratecrate-name resolution) revealed 22 unused dev-dependencies that the old check was silently
missing.
Changes
Pre-commit hook
contrib/dev-tools/git/hooks/pre-commit.sh: changedcargo machete→cargo machete --with-metadataCargo.toml files cleaned up (21 genuine unused dev-deps removed across 13 files)
Cargo.tomllocal-ip-address,mockallpackages/axum-health-check-api-servertracing-subscriberpackages/axum-http-tracker-servertorrust-tracker-events,zerocopypackages/axum-rest-tracker-api-serverlocal-ip-address,mockallpackages/http-tracker-coreformatjson,serde_jsonpackages/peer-idpretty_assertions(entire[dev-dependencies]removed)packages/primitivesrstest(entire[dev-dependencies]removed)packages/server-librstest(entire[dev-dependencies]removed)packages/swarm-coordination-registryasync-std,criterion,rand,torrust-tracker-test-helperspackages/torrent-repository-benchmarkingasync-stdpackages/tracker-corelocal-ip-address,torrust-rest-tracker-api-clientpackages/udp-tracker-coretorrust-tracker-test-helperspackages/udp-tracker-serverlocal-ip-addressFalse-positive handled
serde_bytesinpackages/axum-http-tracker-serveris used via#[serde(with = "serde_bytes")]string attributes in test code —
cargo machetecannot detect this pattern. It is kept andsuppressed via:
CI note
Only
.github/workflows/copilot-setup-steps.ymlexists in this repo and it only installscargo-machete(no invocation) — no CI update was needed.Verification
cargo machete --with-metadata→ "didn't find any unused dependencies. Good job!"cargo build --workspace→ exit 0cargo test --workspace→ all tests passlinter all→ exit 0 (markdownlint, yamllint, taplo, cspell, clippy, rustfmt, shellcheck)225e74fc