Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 817 Bytes

README.md

File metadata and controls

34 lines (23 loc) · 817 Bytes

Cargo Shear

Detect and remove unused dependencies from Cargo.toml in Rust projects.

Usage

cargo install cargo-shear
cargo shear

Technique

  1. use the cargo_metadata crate to list all dependencies specified in [workspace.dependencies] and [dependencies]
  2. iterate through all package targets to locate all Rust files
  3. use syn to parse these Rust files and extract imports
  4. 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

Prior Arts

Trophy Cases