Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
370 changes: 55 additions & 315 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ tracing-subscriber = { version = "0", features = [ "json" ] }
[dev-dependencies]
bittorrent-primitives = "0.2.0"
bittorrent-tracker-client = { version = "3.0.0-develop", path = "packages/tracker-client" }
local-ip-address = "0"
mockall = "0"
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "packages/test-helpers" }

[workspace]
Expand Down
2 changes: 1 addition & 1 deletion contrib/dev-tools/git/hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -uo pipefail
# Each step: "description|command"

declare -a STEPS=(
"Checking for unused dependencies (cargo machete)|cargo machete"
"Checking for unused dependencies (cargo machete --with-metadata)|cargo machete --with-metadata"
"Running all linters|linter all"
"Running documentation tests|cargo test --doc --workspace"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
doc-type: issue
issue-type: task
status: open
status: implemented
priority: p2
github-issue: 1804
spec-path: docs/issues/open/1804-use-cargo-machete-with-metadata-and-remove-unused-dev-deps.md
branch: "1804-use-cargo-machete-with-metadata"
related-pr: null
last-updated-utc: 2026-05-20 00:00
related-pr: 1809
Comment thread
josecelano marked this conversation as resolved.
last-updated-utc: 2026-05-20 12:30
semantic-links:
skill-links:
- create-issue
Expand Down Expand Up @@ -78,47 +78,52 @@ files across the workspace.

Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`.

| ID | Status | Task | Notes / Expected Output |
| --- | ------ | ----------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| T1 | TODO | Run `cargo machete --with-metadata` and record the full list of flagged dependencies | Baseline list; confirm each is genuinely unused before removal |
| T2 | TODO | Update `contrib/dev-tools/git/hooks/pre-commit.sh` to use `cargo machete --with-metadata` | Hook passes with the new flag |
| T3 | TODO | Update CI workflow(s) that call `cargo machete` without `--with-metadata` | CI step passes with the new flag |
| T4 | TODO | Remove flagged unused dependencies from all `Cargo.toml` files | `cargo machete --with-metadata` reports clean after removals |
| T5 | TODO | Run `cargo build --workspace` and `cargo test --workspace` | Clean build; all tests pass |
| T6 | TODO | Run `linter all` | Exit code `0` |
| ID | Status | Task | Notes / Expected Output |
| --- | ------ | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| T1 | DONE | Run `cargo machete --with-metadata` and record the full list of flagged dependencies | 22 unused deps found across 13 packages; 1 false-positive (`serde_bytes`) handled via ignore list |
| T2 | DONE | Update `contrib/dev-tools/git/hooks/pre-commit.sh` to use `cargo machete --with-metadata` | Hook passes with the new flag |
| T3 | DONE | Update CI workflow(s) that call `cargo machete` without `--with-metadata` | N/A — only `copilot-setup-steps.yml` exists in this repo and only installs the tool; does not call it |
| T4 | DONE | Remove flagged unused dependencies from all `Cargo.toml` files | `cargo machete --with-metadata` reports clean after removals |
| T5 | DONE | Run `cargo build --workspace` and `cargo test --workspace` | Clean build; all tests pass |
| T6 | DONE | Run `linter all` | Exit code `0` |

## Progress Tracking

### Workflow Checkpoints

- [x] Spec drafted in `docs/issues/drafts/`
- [ ] Spec reviewed and approved by user/maintainer
- [ ] GitHub issue created and issue number added to this spec
- [ ] Spec moved to `docs/issues/open/` with issue number prefix
- [ ] Implementation completed
- [ ] Automatic verification completed (`linter all`, `cargo test --workspace`)
- [ ] Manual verification scenarios executed and recorded (status + evidence)
- [ ] Acceptance criteria reviewed after implementation and updated with evidence
- [x] Spec reviewed and approved by user/maintainer
- [x] GitHub issue created and issue number added to this spec
- [x] Spec moved to `docs/issues/open/` with issue number prefix
- [x] Implementation completed
- [x] Automatic verification completed (`linter all`, `cargo test --workspace`)
- [x] Manual verification scenarios executed and recorded (status + evidence)
- [x] Acceptance criteria reviewed after implementation and updated with evidence
- [ ] Reviewer validated acceptance criteria and updated checkboxes
- [ ] Committer verified spec progress is up to date before commit
- [x] Committer verified spec progress is up to date before commit
- [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/`

### Progress Log

- 2026-05-20 00:00 UTC - josecelano - Spec drafted. Root cause identified: plain `cargo machete`
has false negatives for dev dependencies; `--with-metadata` mode is accurate. Full list of
unused deps generated by running `cargo machete --with-metadata` in the workspace.
- 2026-05-20 12:30 UTC - josecelano - Implementation complete. Removed 21 genuine unused
dev-deps across 13 `Cargo.toml` files; 1 machete false-positive (`serde_bytes` in
`axum-http-tracker-server`, used via `#[serde(with = "serde_bytes")]` string attribute)
kept and suppressed via `[package.metadata.cargo-machete] ignored`. T3 is N/A — no CI
workflow in this repo calls plain `cargo machete`. Commit: `225e74fc`.

## Acceptance Criteria

- [ ] AC1: The pre-commit hook calls `cargo machete --with-metadata` (not plain `cargo machete`).
- [ ] AC2: All CI workflow steps that call `cargo machete` use `--with-metadata`.
- [ ] AC3: `cargo machete --with-metadata` exits `0` across the entire workspace (no unused deps).
- [ ] AC4: `cargo build --workspace` and `cargo test --workspace` pass cleanly after dep removals.
- [ ] AC5: `linter all` exits with code `0`.
- [ ] Manual verification scenarios are executed and documented (status + evidence).
- [ ] Acceptance criteria are re-reviewed after implementation and reflect actual behavior.
- [ ] Documentation is updated when behaviour or workflow changes.
- [x] AC1: The pre-commit hook calls `cargo machete --with-metadata` (not plain `cargo machete`).
- [x] AC2: All CI workflow steps that call `cargo machete` use `--with-metadata` (N/A — no CI step calls it in this repo).
- [x] AC3: `cargo machete --with-metadata` exits `0` across the entire workspace (no unused deps).
- [x] AC4: `cargo build --workspace` and `cargo test --workspace` pass cleanly after dep removals.
- [x] AC5: `linter all` exits with code `0`.
- [x] Manual verification scenarios are executed and documented (status + evidence).
- [x] Acceptance criteria are re-reviewed after implementation and reflect actual behavior.
- [x] Documentation is updated when behaviour or workflow changes.

## Verification Plan

Expand All @@ -133,21 +138,21 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`.

Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`.

| ID | Scenario | Command/Steps | Expected Result | Status | Evidence |
| --- | -------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------ | ------ | -------- |
| M1 | Pre-commit hook uses `--with-metadata` | `grep machete contrib/dev-tools/git/hooks/pre-commit.sh` | Output includes `--with-metadata` | TODO | |
| M2 | No unused deps remain after removals | `cargo machete --with-metadata` | "didn't find any unused dependencies. Good job!" | TODO | |
| M3 | Workspace builds and tests pass after dep removals | `cargo build --workspace && cargo test --workspace` | Both commands exit `0` | TODO | |
| ID | Scenario | Command/Steps | Expected Result | Status | Evidence |
| --- | -------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------ | ------ | -------------------------------------------------------------------------------- |
| M1 | Pre-commit hook uses `--with-metadata` | `grep machete contrib/dev-tools/git/hooks/pre-commit.sh` | Output includes `--with-metadata` | DONE | Line confirms: `cargo machete --with-metadata` |
| M2 | No unused deps remain after removals | `cargo machete --with-metadata` | "didn't find any unused dependencies. Good job!" | DONE | `cargo-machete didn't find any unused dependencies in this directory. Good job!` |
| M3 | Workspace builds and tests pass after dep removals | `cargo build --workspace && cargo test --workspace` | Both commands exit `0` | DONE | Both exit `0`; full test suite passes |

### Acceptance Verification

| AC ID | Status (`TODO`/`DONE`) | Evidence |
| ----- | ---------------------- | -------- |
| AC1 | TODO | |
| AC2 | TODO | |
| AC3 | TODO | |
| AC4 | TODO | |
| AC5 | TODO | |
| AC ID | Status (`TODO`/`DONE`) | Evidence |
| ----- | ---------------------- | ------------------------------------------------------------------------------------------------------ |
| AC1 | DONE | `grep` on pre-commit.sh confirms `cargo machete --with-metadata` |
| AC2 | DONE | N/A — no CI workflow in this repo calls `cargo machete` directly |
| AC3 | DONE | `cargo machete --with-metadata` exits `0`: "didn't find any unused dependencies. Good job!" |
| AC4 | DONE | `cargo build --workspace` and `cargo test --workspace` both exit `0` |
| AC5 | DONE | `linter all` exits `0`: all linters (markdown, yaml, toml, cspell, clippy, rustfmt, shellcheck) passed |

## Risks and Trade-offs

Expand Down
1 change: 0 additions & 1 deletion packages/axum-health-check-api-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ torrust-axum-rest-tracker-api-server = { version = "3.0.0-develop", path = "../a
torrust-tracker-clock = { version = "3.0.0-develop", path = "../clock" }
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }
torrust-udp-tracker-server = { version = "3.0.0-develop", path = "../udp-tracker-server" }
tracing-subscriber = { version = "0", features = [ "json" ] }
7 changes: 5 additions & 2 deletions packages/axum-http-tracker-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ serde_bencode = "0"
serde_bytes = "0"
serde_repr = "0"
torrust-tracker-clock = { version = "3.0.0-develop", path = "../clock" }
torrust-tracker-events = { version = "3.0.0-develop", path = "../events" }
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }
uuid = { version = "1", features = [ "v4" ] }
zerocopy = "0.8"

# cargo-machete cannot detect `serde_bytes` usage via `#[serde(with = "serde_bytes")]`
# string attributes in test code; suppress the false-positive.
[package.metadata.cargo-machete]
ignored = [ "serde_bytes" ]
2 changes: 0 additions & 2 deletions packages/axum-rest-tracker-api-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ tracing = "0"
url = "2"

[dev-dependencies]
local-ip-address = "0"
mockall = "0"
torrust-rest-tracker-api-client = { version = "3.0.0-develop", path = "../rest-tracker-api-client" }
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }
url = { version = "2", features = [ "serde" ] }
Expand Down
2 changes: 0 additions & 2 deletions packages/http-tracker-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ torrust-tracker-swarm-coordination-registry = { version = "3.0.0-develop", path
tracing = "0"

[dev-dependencies]
formatjson = "0.3.1"
mockall = "0"
serde_json = "1.0.140"
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }

[[bench]]
Expand Down
3 changes: 0 additions & 3 deletions packages/peer-id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ quickcheck = { version = "1", optional = true }
regex = "1"
serde = { version = "1", features = [ "derive" ], optional = true }
zerocopy = { version = "0.8", features = [ "derive" ], optional = true }

[dev-dependencies]
pretty_assertions = "1"
3 changes: 0 additions & 3 deletions packages/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ tdyne-peer-id-registry = "0"
thiserror = "2"
torrust-net-primitives = { version = "3.0.0-develop", path = "../net-primitives" }
torrust-tracker-clock = { version = "3.0.0-develop", path = "../clock" }

[dev-dependencies]
rstest = "0.25.0"
3 changes: 0 additions & 3 deletions packages/server-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ tokio = { version = "1", features = [ "macros", "net", "rt-multi-thread", "signa
torrust-net-primitives = { version = "3.0.0-develop", path = "../net-primitives" }
tower-http = { version = "0", features = [ "compression-full", "cors", "propagate-header", "request-id", "trace" ] }
tracing = "0"

[dev-dependencies]
rstest = "0.25.0"
4 changes: 0 additions & 4 deletions packages/swarm-coordination-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,5 @@ torrust-tracker-primitives = { version = "3.0.0-develop", path = "../primitives"
tracing = "0"

[dev-dependencies]
async-std = { version = "1", features = [ "attributes", "tokio1" ] }
criterion = { version = "0", features = [ "async_tokio" ] }
mockall = "0"
rand = "0"
rstest = "0"
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }
1 change: 0 additions & 1 deletion packages/torrent-repository-benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ torrust-tracker-configuration = { version = "3.0.0-develop", path = "../configur
torrust-tracker-primitives = { version = "3.0.0-develop", path = "../primitives" }

[dev-dependencies]
async-std = { version = "1", features = [ "attributes", "tokio1" ] }
criterion = { version = "0", features = [ "async_tokio" ] }
rstest = "0"

Expand Down
2 changes: 0 additions & 2 deletions packages/tracker-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ testcontainers = "0"
tracing = "0"

[dev-dependencies]
local-ip-address = "0"
mockall = "0"
torrust-rest-tracker-api-client = { version = "3.0.0-develop", path = "../rest-tracker-api-client" }
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }
url = "2.5.4"
1 change: 0 additions & 1 deletion packages/udp-tracker-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ zerocopy = "0.8"

[dev-dependencies]
mockall = "0"
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }

[[bench]]
harness = false
Expand Down
1 change: 0 additions & 1 deletion packages/udp-tracker-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ uuid = { version = "1", features = [ "v4" ] }
zerocopy = "0.8"

[dev-dependencies]
local-ip-address = "0"
mockall = "0"
rand = "0"
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }
Loading