Repository navigation
v0.1.0: the first release, with dependency, visibility, file, structure and mutation checks
The first release of cargo-fallow: codebase analysis for Rust workspaces, as a Cargo subcommand. It finds unused dependencies, public items that are too visible, files that no target compiles, copied code, complex functions, boundary violations and growing files. It also runs mutation tests. The static checks read cargo metadata and the syntax tree, so you do not have to compile the workspace first.
cargo install cargo-fallow --locked
cargo fallowChecks
cargo fallow checkruns each static check and writes one report. The report has a 0 to 100 health score and a gate table. The human output ends with the gates that fail and a next step.--hotspotsranks the files that are complex and change often,--file-scoresadds the maintainability index of each file, and--save-snapshotwith--trendcompares a run with an earlier score.cargo fallow depsfinds unused, misplaced and feature-only dependencies. Theunused-featurerule reports a feature of apublish = falsepackage that turns on nothing and that no code names.cargo fallow visibilityfindspubitems that are too visible. It reports dead public items and items that only their own crate uses. The exported API of a library that a registry can publish counts as an entry point, so a published crate gets no finding for its own API.--preciseadds a rust-analyzer pass for method calls and macro output.cargo fallow filesfinds.rsfiles that no target compiles.cargo fallow dupes,complexity,boundariesandsizereport clone groups, functions over the complexity limits, crate and module rule violations, and files that grow past their line limits.cargo fallow mutantsruns mutation tests. It selects the tests of each mutant from a coverage map. It is opt-in, because it builds the workspace and runs its tests.
Fixes and workflow
cargo fallow fixapplies the safe fixes. It removes unused dependency entries, moves misplaced entries to[dev-dependencies]and narrows visibility keywords. The edit keeps the format and the comments ofCargo.toml.fixrunscargo checkbefore and after a visibility edit, and writes the old files back when the check fails. Run--dry-runfirst to see the edits.cargo fallow initwrites a starting configuration. It sets each limit at the current maximum and saves the current findings as a baseline, so a gate starts green on an existing workspace.--ci githubprints a workflow.--changed-since <REF>and--baseline <PATH>keep a pull request focused. The first keeps the findings in the files that changed since the fork point of the ref. The second leaves out the findings of a saved baseline.- Suppression comments work for each check. Use
// fallow-ignore-next-line <kind>or// fallow-ignore-file <kind>in a.rsfile, and# fallow-ignore-next-line <rule>inCargo.toml. A comment that hides no finding gives astale-suppressionwarning. [workspace.metadata.fallow.rules]sets each rule toerror,warnoroff. A finding that counts for a gate has the severityerror. A rule atwarnreports the finding but does not fail the gate.cargo fallow explain <rule>gives the meaning, an example and the fix of a rule.--traceshows why a check keeps or reports one item, one dependency or one clone group.
Output and CI
- Formats: human, JSON, SARIF, compact, markdown,
github-annotations,github-summaryand an SVGbadgewith the health grade.cargo fallow schemaprints the JSON Schema of each JSON document. - Exit codes: 0 when no enforced gate fails, 1 when a gate fails, and 2 for an error.
- The GitHub Action installs a verified release binary, runs the checks, writes annotations and a job summary, and can post one sticky pull request comment. It accepts
changed-since,baselineandsave-baseline. - The GitLab CI template writes the code quality report of the merge request widget, and can post one merge request note.
--locked,--offlineand--frozenreach eachcargo metadatacall.
Release artifacts
Each archive has a SHA-256 checksum, an Ed25519 signature (.sig) and a build provenance attestation. The GitHub Action installer checks the signature and the checksum before it runs the binary, and fails closed. To check an archive by hand, run gh attestation verify <archive> --repo fallow-rs/cargo-fallow.
cargo-fallow is at version 0.x, so the JSON output can change in a minor release. The CHANGELOG lists each change.
Full changelog: https://github.com/fallow-rs/cargo-fallow/commits/v0.1.0