rint
A linter, written in Rust, that stops Rust code from eroding one change at a time. Every change looks fine on its own; the damage is the slope. rint scores a whole tree and, given a git base, fails when a score gets worse, rather than enforcing a fixed limit that can be sat under forever (complexity 9 passes a limit of 10 every time; it cannot pass a ratchet).
The signals come from SlopCodeBench (arXiv 2603.24755). Test code is never scored as product code.
HANDOFF.md has the research and the decisions this is built on.
Use
Everything runs through mise. It installs buck2, reindeer and rust-script; the nix devshell adds the
C compiler mise cannot bring, so on a bare machine prefix each command with nix develop -c.
mise trust && mise install the toolchain
mise tasks what can be run
mise run test every test, through buck2
mise run rint -- check score this tree (or: -- check --path ~/some-repo)
mise run rint -- diff HEAD~5 fail if anything got worse since HEAD~5
mise run dogfood rint on its own source
The binary takes the same arguments directly (buck2 build //crates/rint-cli:rint, or cargo rint
once cargo-rint is on PATH):
rint check score the tree; a report, exit 0 unless rint.toml sets deny or limits
rint check --base <rev> the same, then compare with the git revision
rint diff <rev> the comparison only
rint erosion | concentration | clones | wrappers | single-use | dispatch
| allows | tests | branches | casts | lets | graph one signal each
global flags: -C <dir> --config <file> --format text|json
Exit codes: 0 clean, 1 a regression or a violation, 2 a usage or internal error. The base revision is read with git without checking it out, so a dirty work tree is fine.
Install
rint is released for Linux (x86_64 and aarch64, static musl), macOS (Apple silicon and Intel) and Windows
(x86_64) as signed packslip archives, each holding rint and cargo-rint. In a repository's mise.toml:
[tools]
"packslip:github.com/jevgineer/rint" = { version = "0.1.0", pubkey = "RWRBRJ8J7sFC5gpZdjHhDlYlF4P0YsYpi1c5AwnlNsoSYiYyCCR3Alnq", allow_unlogged = true }
allow_unlogged is needed because the release is signed with a key and not recorded in a public
transparency log; pubkey is tools/release.pub. mise run release:build and
mise run release:sign make a release, and mise run release:refresh signs the list of releases again
before it expires; none publishes anything.
The repository is public, but GitHub answers 404 to everyone except the jevgineer account for
every jevgineer repository (measured 2026-11-02: api.github.com/repos/jevgineer/rint is 404
anonymously and with another account's token, 200 with jevgineer's). Until that lifts, mise
needs that account's token in GITHUB_TOKEN to find the release.
The same release is served without a token by the code host, which reads GitHub with its own
token: "packslip:code.lmjtfy.fun/rint" in place of "packslip:github.com/jevgineer/rint",
same version and pubkey (the list is https://code.lmjtfy.fun/.well-known/packslip/rint.json).
Only pinned versions resolve there while the account is hidden: GitHub lists the account's
releases as empty, so latest is 404. And the hidden account's API quota is 60 requests an hour
(measured 2026-11-07), of which the code host uses at most 30; when they are spent it answers
502 GitHub did not answer for every release file until the hour's reset.
What it measures
Complexity is computed twice, cyclomatic (the paper's measure, threshold 10) and cognitive (SonarSource's, threshold 15), and every score is reported and ratcheted separately for each.
| Signal | What it finds | Ratchet |
|---|---|---|
| erosion | share of complexity mass (complexity * sqrt(sloc)) in functions above the threshold | rise beyond tolerance |
| concentration | Gini of mass across functions, and the top-20% share | rise beyond tolerance |
| function growth | a function's cyclomatic, cognitive or nesting grew above a floor, or a new one starts above the threshold | any |
| clones | normalised-token windows repeated across functions | clone ratio rises |
| wrappers | private fns whose whole body forwards their arguments to one call | any new |
| single-use | private fns with exactly one call site (name-based); a fn on a call cycle, directly or through other fns, is skipped | any new, as a warning |
| dispatch | match / if chains comparing one value to four or more string literals | any new |
| branches | sibling match arms / if branches with token-identical bodies (names and literals kept, so mergeable with |); bodies differing only in a name belong to clones | any new |
| allows | #[allow(..)] attributes, except those whose lints are all in [allows] permitted | any new |
| casts | .clone() or as heavy functions, Rc<RefCell<..>>, Box<dyn Any> | any new |
| lets | let x = ..; read once, in the very next statement | any new, as a warning |
| graph | module cycles and propagation cost per crate (use edges) | new cycle, cost rises |
| tests | test inventory; public functions no test mentions | informational, never fails |
Test code is a #[cfg(test)] item, a #[test] / #[bench] / #[tokio::test] function, or any file
under tests/, benches/, examples/ (configurable). It is read only to count references to
product names.
Flat matches. A match with no catch-all arm (_ or a lowercase binding), no guards, and no
branching inside any arm counts 1 in cyclomatic, not one per arm: the "modified cyclomatic complexity"
of Lizard (-m) and SciTools Understand. Without a catch-all the compiler checks exhaustiveness, so
adding a variant to a data enum is not new logic. Cognitive already scores any match as +1. A match
that fails the test counts per arm as before; [complexity] flat_match = "per_arm" turns this off.
Warnings. single-use and lets are reported by check and diff (text and JSON both carry a
severity of warning) but never fail the ratchet or a plain check. rint judges them by shape alone: a
let can be required by the borrow checker (E0499, E0502) and syn cannot see that, and single-use
helpers are often exactly what the growth gate asked a long function to be split into.
Configuration
rint.toml at the scanned root (or --config). Every threshold, with its default, is listed in this
repository's own rint.toml. Unknown keys are an error. The numbers are starting guesses.
deny = [..]names signals whose findings fail a plaincheck; it also makes a warning signal an error again, sodeny = ["lets"]opts a repository back in.warn = [..]is the list of warning signals, default["single-use", "lets"];warn = []makes every signal an error.[allows] permitted = ["refining_impl_trait", ..]: an#[allow(..)]whose lints are all listed is not a finding. Names match exactly as written, soclippy::too_many_argumentsandtoo_many_argumentsare separate entries.[complexity] flat_match = "one" | "per_arm", default"one".
Clippy preset
clippy-preset/ ships a clippy.toml and a lint list for what Clippy can enforce per function, so
rint does not reimplement it. See clippy-preset/.
First runs
Read-only runs of the binary built from this tree, 2026-11-01 (rint reads files and git show; it
wrote nothing in either repository). check is the plain report; diff HEAD~5 is the ratchet against
five commits back, and exits 1 in both repositories because both grew.
~/bootspan | ~/jevboard | ~/rint (itself) | |
|---|---|---|---|
| functions / sloc / files | 134 / 1,259 / 12 | 3,528 / 36,768 / 330 | 167 / 2,022 / 25 |
| erosion, cyclomatic / cognitive | 0.000 / 0.000 | 0.349 / 0.450 | 0.280 / 0.266 |
| high functions (above 10 / above 15) | 0 / 0 | 119 / 80 | 8 / 4 |
| largest function | 9 / 7 | 60 / 82 | 16 / 31 |
| Gini of mass, cyclomatic / cognitive | 0.490 / 0.716 | 0.676 / 0.857 | 0.607 / 0.765 |
| top-20% share | 0.530 / 0.731 | 0.726 / 0.895 | 0.660 / 0.793 |
| clone ratio | 0.011 | 0.062 (238 regions) | 0.011 |
| wrappers / single-use / dispatch | 4 / 35 / 0 | 21 / 341 / 15 | 0 / 39 / 0 |
| branches / allows / casts / lets | 1 / 0 / 0 / 42 | 93 / 12 / 60 / 1,165 | 8 / 0 / 0 / 63 |
| module cycles | 0 | 17 | 0 |
What the ratchet found. In bootspan, diff HEAD~5 fails on three new single-use helpers
(number_json, text_json, container_json), while erosion fell from 0.069 to 0.000 over the same
five commits: the shape of a function being split up. In jevboard it fails on 54 items: ten functions
that grew (resolve in packages/node/src/entities.rs went from cyclomatic 8 to 18; Because::fmt 13
to 15), four new functions that start above the threshold (Facts::join_said, cognitive 28), a new
#[allow(clippy::too_many_arguments)], a new five-arm string match in packages/records, a
function with eight .clone() calls, two new module cycles in packages/config and packages/prefs,
the prefs propagation cost rising 0.654 to 0.680, and 27 single-use lets.
On itself. Both complexity measures concentrate in a few functions (Walker::visit_expr,
cyclomatic 16; signals::clones::find; signals::scc::components, cognitive 31), and the exec and
collect modules have several two-arm matches with equal bodies. Those are real findings and are left
as found; rint diff on this repository is the check that they do not get worse.
How much to trust it. The thresholds are untuned guesses, and these runs show which signals are
noisy. lets (1,165 in jevboard) and single-use (341) fire on a great deal of ordinary, readable
code, so as plain counts they are not informative; they are useful only as the ratchet's "new since the
base". The module-cycle finding counts a parent module and its child importing from each other, which
is common in Rust and real, but a lower-severity cycle than two siblings. Two defects were found and
fixed by these runs: files pulled in by #[cfg(test)] mod tests; (also with #[path]) were being
scored as product code, and an unchanged erosion printed as -0.000.
Layout
| Path | What |
|---|---|
crates/rint-core | the engine: parse with syn, measure, score, compare |
crates/rint-cli | the command line (library rint_cli and the rint binary) |
crates/cargo-rint | the cargo rint forwarder |
clippy-preset/ | clippy.toml and the recommended deny list |
rint.toml | rint's own configuration |
tools/ | repository scripts (rust-script) |
platforms/, toolchains/, third-party/, .buckconfig | buck2 build setup, shared with the estate's other repositories |
HANDOFF.md | the research and decisions |
Outstanding
- dylint lints (a later, optional phase; not built): the checks that need types, such as a
.clone()that exists only to satisfy the borrow checker, aResultthat can never beErr, a needlessascast. They need a pinned nightly and compiling code, which is why the syn core does not try. - Dependency entropy, the paper's third graph metric: only cycles and propagation cost are built.
- Thresholds are untuned. They are guesses; tuning needs real before/after pairs of agent-written changes, which this repository does not have.
- Extra defensive checks (a
Result/Optionthat is neverErr/None) need types: dylint. - Name-based approximations: single-use, the untested-public list and recursion detection match by name, because syn does no name resolution. Names defined more than once are skipped.