Skip to content

v0.1.0: the first release, with dependency, visibility, file, structure and mutation checks

Choose a tag to compare

@github-actions github-actions released this 04 Nov 15:34
· 102 commits to main since this release
v0.1.0
9a2ddc7

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 fallow

Checks

  • cargo fallow check runs 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. --hotspots ranks the files that are complex and change often, --file-scores adds the maintainability index of each file, and --save-snapshot with --trend compares a run with an earlier score.
  • cargo fallow deps finds unused, misplaced and feature-only dependencies. The unused-feature rule reports a feature of a publish = false package that turns on nothing and that no code names.
  • cargo fallow visibility finds pub items 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. --precise adds a rust-analyzer pass for method calls and macro output.
  • cargo fallow files finds .rs files that no target compiles.
  • cargo fallow dupes, complexity, boundaries and size report clone groups, functions over the complexity limits, crate and module rule violations, and files that grow past their line limits.
  • cargo fallow mutants runs 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 fix applies 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 of Cargo.toml. fix runs cargo check before and after a visibility edit, and writes the old files back when the check fails. Run --dry-run first to see the edits.
  • cargo fallow init writes 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 github prints 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 .rs file, and # fallow-ignore-next-line <rule> in Cargo.toml. A comment that hides no finding gives a stale-suppression warning.
  • [workspace.metadata.fallow.rules] sets each rule to error, warn or off. A finding that counts for a gate has the severity error. A rule at warn reports the finding but does not fail the gate.
  • cargo fallow explain <rule> gives the meaning, an example and the fix of a rule. --trace shows 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-summary and an SVG badge with the health grade. cargo fallow schema prints 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, baseline and save-baseline.
  • The GitLab CI template writes the code quality report of the merge request widget, and can post one merge request note.
  • --locked, --offline and --frozen reach each cargo metadata call.

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