Cargo Shear
Detect and remove unused dependencies from Cargo.toml in Rust projects.
Technique
- use the
cargo_metadatacrate to list all dependencies specified in[workspace.dependencies]and[dependencies] - iterate through all package targets to locate all Rust files
- use
synto parse these Rust files and extract imports - identify the difference between the imports and the package dependencies
TODO
- make the reporting more granular for
[dependencies],[dev-dependencies]and[build-dependencies] -
--fix - add tests
- exit codes
- error recovery
- print things more nicely