Crates.io | cargo-shear |
lib.rs | cargo-shear |
version | 1.1.0 |
source | src |
created_at | 2024-03-15 09:33:30.855157 |
updated_at | 2024-07-10 13:11:00.335851 |
description | Detect and remove unused dependencies from Cargo.toml |
homepage | |
repository | https://github.com/Boshen/cargo-shear |
max_upload_size | |
id | 1174532 |
size | 50,553 |
Detect and remove unused dependencies from Cargo.toml
in Rust projects.
cargo binstall cargo-shear
# OR
cargo install cargo-shear
cargo shear --fix
[!IMPORTANT]
cargo shear
cannot detect dependency usages from macros because it usessyn
to parse the files
False positives can be ignored by adding them to the package's Cargo.toml
:
[package.metadata.cargo-shear]
ignored = ["crate"]
or in workspace's Cargo.toml
:
[workspace.metadata.cargo-shear]
ignored = ["crate"]
Otherwise please report the issue as a bug.
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: Install cargo-shear
run: cargo binstall --no-confirm cargo-shear
- run: cargo shear
The exit code gives an indication whether unused dependencies have been found:
cargo_metadata
crate to list all dependencies specified in [workspace.dependencies]
and [dependencies]
lib
, bin
, example
, test
and bench
) to locate all Rust filessyn
to parse these Rust files and extract importstarget/
directorycargo