Skip to content

Releases

v0.3.0: agent integration, fuzz consumers and safer fix

Choose a tag to compare

@BartWaardenburg BartWaardenburg released this 06 Nov 07:11
Immutable release. Only release title and notes can be modified.
v0.3.0
fdcf25a

This release connects cargo-fallow to coding agents. A gate stops an agent commit or push that adds a new finding, and a skill tells the agent how to use each command. The release also makes fix continue past one bad edit, and lets fuzz targets count as users of workspace items.

cargo install cargo-fallow --locked

Coding agents

  • cargo fallow hooks install --target agent installs a gate for Claude Code and Codex. Before an agent runs git commit or git push, the gate runs cargo fallow check on the changed files. It blocks only a finding that the base commit does not have, and it lists each finding. An error of the tool does not block.
  • cargo fallow hooks install --target git installs the same check as a git pre-commit hook. hooks uninstall removes the files, and hooks status shows them.
  • The cargo-fallow skill tells a coding agent how to run each command, read the JSON output and fix the findings after a block. The skill is in skills/cargo-fallow/SKILL.md, with a Codex interface file. The Fallow plugin also contains it.
  • cargo fallow agent install sets up a repository in one step: a guide block in AGENTS.md, the skill for Claude Code and Codex, and the gate. agent status shows the parts, and agent uninstall removes them. cargo fallow init --agents runs the same setup.

Use a release build of cargo-fallow with the gate. On a large workspace, a debug build can take more time than the hook timeout of the agent.

Configuration and checks

  • consumers in [workspace.metadata.fallow.visibility] lists separate workspaces that use the items of the workspace, for example fuzz/Cargo.toml. visibility then does not report an item that a fuzz target calls, and fix does not narrow it. Without the key, fuzz/Cargo.toml counts when it exists.
  • A boundaries.sources rule reports an allow entry whose file has fewer matches than max. The finding kind is allow-entry, so the list stays exact. An entry can also take require = ["pattern"], so the file must contain each pattern.
  • cargo fallow api --public-crate <CRATE> sets the external libraries for one run. --all-published reads each published library.

cargo fallow fix

  • fix no longer stops the run for one edit that adds a compiler warning or error. It leaves out that edit, applies the others, and records the reason in skip_reason and diagnostic.
  • The guard now sees a new dead_code warning, so an edit that makes an item dead is left out.
  • The guard also builds each consumers workspace.

Changed behavior

  • A dead-public finding and a finding with test_only: true are no longer auto_fixable. A narrower keyword on such an item makes the compiler report dead code. A dead-public finding has a second action, remove-item.
  • cargo fallow api --base reads the same libraries that visibility treats as an external API. When public-crates is set, a narrowed item of an internal crate is no longer a removed finding.
  • cargo fallow init --ci github writes fallow-rs/cargo-fallow@v0, the newest 0.x release, and not @main.

Fixes

  • The GitHub Action and the GitLab CI template now work with a jq that ends each line with CRLF, as jq on Windows does. Before, the gate outputs, the annotation count, the job summary and the GitLab note pages kept a CR. With bash 3.2, the GitLab comment step could loop without end.

v0.2.0...v0.3.0

v0.2.0: API change check, new boundary rules and CRAP scores

Choose a tag to compare

@BartWaardenburg BartWaardenburg released this 05 Nov 15:32
Immutable release. Only release title and notes can be modified.
v0.2.0
b8ef4a6

This release adds an API change check, new boundary rules and CRAP scores. It also makes fix safer, and the GitHub Action now meets the GitHub Marketplace rules.

cargo install cargo-fallow --locked

New checks

  • cargo fallow api --base <REF> reports the public API changes of each published library. It lists the added, removed and changed items, and the crates and features that were added or removed. The api-removals gate fails when an item was removed and the breaking part of the version did not change. The GitHub Action runs it with command: api and the base input.
  • cargo fallow boundaries has three new rule types. Item rules keep some packages from a workspace item, also through use, aliases and re-exports. Glob re-export rules find a pub use <path>::* that reads a denied crate or module. cfg rules report a path from code that a cfg build compiles to an item that the same build does not compile.
  • boundaries.sources rules take scope = "production" and allow = [{ path, max }]. The first skips test code. The second lets a listed file have up to max matches.
  • cargo fallow deps has the opt-in feature-unification-drift rule. It reports a shared crate that gets other features in cargo build -p <member> than in cargo build --workspace.
  • --coverage <LCOV> gives each function a CRAP score in complexity and check. A function at or over max-crap (default 30) is a complexity-crap finding.

Configuration

  • cyclomatic-policy = "flat-match" counts a flat match, for example a lookup table, as one decision. The default stays standard.
  • cargo fallow dupes --production and production = true leave test code out of the clone search.
  • cargo fallow visibility --public-crate and the public-crates key name the libraries that are an external API. Each other library gets each rule.
  • cargo fallow check accepts --base <REF> and --staged, so one check run covers the file-growth gate. The GitHub Action passes its base input to check.

cargo fallow fix

  • fix formats each changed file with rustfmt when the file was formatted before the edits.
  • --only <CHECK> and --skip <CHECK> limit the edits to deps or visibility.
  • fix leaves out an edit that adds a compiler warning. Before, a workspace that builds with -D warnings could break after fix exited 0.

Changed behavior

  • The SARIF level of a finding now follows its severity: error gives error, and warn gives warning. A gate flag no longer changes the level. A deps warning is now a SARIF warning, not a note.
  • With code-duplication = "off", the duplication-threshold gate still judges the percentage. To drop the gate, remove threshold from [workspace.metadata.fallow.dupes].

Fixes

  • cargo fallow visibility gives credit to intra-doc links in more forms, so fix no longer breaks cargo doc. It also no longer reports items where pub(crate) causes a rustc or clippy error: a type in the signature of a pub item, a #[cfg(test)] pub item in a private module, and an item that a use with a written visibility re-exports.
  • cargo fallow deps counts an intra-doc link to a dependency as a use.
  • cargo fallow mutants gives --locked, --offline and --frozen to each cargo call in the copies.
  • The GitHub Action fails the step when base: auto cannot read the base commit of a gate that needs it. Before, the growth gate passed without a check.
  • The GitHub Action and the GitLab template post no first comment for a clean run.
  • The description of the GitHub Action now fits the Marketplace limit.

Performance

  • cargo fallow check parses each file one time. On a large workspace, the run uses about 14% less CPU time.
  • The memory of cargo fallow visibility now grows about linearly with the source size. On a generated 5 MB file, the peak memory goes from 8.9 GB to 1.5 GB, and the time from 33 s to 1.5 s.

v0.1.0...v0.2.0

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
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