chore(clippy): make the lint gate exit 0, decide 6.28 #24

Open
ben wants to merge 4 commits from chore/clippy-green into main
Owner

What changed

cargo clippy --all-targets -- -D warnings exits 0 on this branch, in both the
debug and the release profile. AGENTS.md and CONTRIBUTING.md list it as a
gate next to cargo fmt --check.

6.28 in engine::glitch_pre was a truncated TAU: every other pattern in that
function multiplies the animation phase by std::f32::consts::TAU, so the
argument for keeping it as a named constant had nothing behind it. The other 143
warnings are cleared without touching behaviour.

Why

clippy::approx_constant is deny-by-default, so clippy stopped at that line and
nobody could see the rest — a new warning could not be noticed. Fixes #4.

The 6.28 decision, measured

A 96×72 sample::sample rendered with smooth-diffuse, FNV-1a over the RGBA
output, before → after:

phase before after
0.00 775eedb743d95ae3 775eedb743d95ae3
0.13 c60e7a43f7c414fb c60e7a43f7c414fb
0.37 28455376d7e58966 28455376d7e58966
0.50 a89a9984b5d87b9b 7188532671eaa0d3
0.71 3f5c7b8d59ac181b 3f5c7b8d59ac181b
0.99 1903ae281e599fcb 1903ae281e599fcb

So every static render (--render, --audit, --selftest, the 1-bit
fingerprints) is bit-identical: they render at phase 0. One animation frame
changes — phase 0.5, the half turn, where 0.05 % of a turn decides which way a
sub-pixel displacement rounds: 1396 of 6912 pixels differ, up to one row of
shift. That is the hair the issue predicted, and it is the half turn where the
wobble is supposed to be exactly inverted.

The 143 warnings

  • 74 field_reassign_with_default (173 assignments) → the literal they were
    building field by field; 4 comparators → sort_by_key with Reverse;
    chunks_exact(n) → as_chunks::<n>(); needless borrows and casts, ifs with
    two identical arms, .err().expect() → expect_err, a Default impl that is
    a derive, Tab::EffectTab → Tab::Effect.
  • theme.rs's test module sat before other items and moved, unchanged, to the
    end of the file (the file's lines are otherwise identical apart from one
    assert_eq!(…, true) → assert!).
  • Kept with the reason next to them: engine::adjust (#[allow(dead_code)], it
    is the single-colour path the LUT replaced) and engine::cell_threshold
    (#[allow(clippy::too_many_arguments)], eight arguments that a struct would
    turn into a per-pixel allocation).
  • Deleted because nothing called them: engine::bayer16, engine::build_lut,
    shapes_data::find, halftone::Screen::cells_per_side, two unused test
    helpers. fx::tile_ok was a duplicate of what tile_problem checks inline, so
    tile_problem now asks it.
  • shape::remove_band had two arms that removed the same stop; they are one
    if with a comment saying why the index needs no second test.

Checks

Run on the branch tip 5e78b45 (the three commits are below):

  • cargo fmt --check
  • cargo test --release — 256 passed
  • opendither --audit — 558 checks, 558 passed, 1 skipped
  • opendither --controls — 62 checked, 0 failed
  • opendither --uitest — 111 checks, 111 passed
  • opendither --selftest — 456 renders, 0 failures
  • cargo clippy --all-targets -- -D warnings — exit 0, debug and release

The lint pass alone: cargo clippy --all-targets went from one deny-level
error and 139 warnings to 0 and 0 (143 warning lines by clippy's own count, 88
of them duplicates of the same site).

Not checked

Nothing was cross-built for Windows; no cfg(windows) code was touched, but the
release build in README.md › Release builds was not run.

Notes for the reviewer

  • Three commits: the 6.28 decision (fix(engine)), the warning pass
    (chore(clippy)) and the two documentation lines (docs) — plus the
    .git-blame-ignore-revs entry for the pass.

  • The cleanup commit is in .git-blame-ignore-revs, so git blame looks through
    it (that file needs git config blame.ignoreRevsFile .git-blame-ignore-revs).

  • The suites have no row that pins clippy itself — there is no CI on this
    repository, so the gate is the line in AGENTS.md plus the reviewer. A CI job
    that runs the six commands would close that, and is more than this issue asks
    for.

## What changed `cargo clippy --all-targets -- -D warnings` exits 0 on this branch, in both the debug and the release profile. `AGENTS.md` and `CONTRIBUTING.md` list it as a gate next to `cargo fmt --check`. `6.28` in `engine::glitch_pre` was a truncated `TAU`: every other pattern in that function multiplies the animation phase by `std::f32::consts::TAU`, so the argument for keeping it as a named constant had nothing behind it. The other 143 warnings are cleared without touching behaviour. ## Why `clippy::approx_constant` is deny-by-default, so clippy stopped at that line and nobody could see the rest — a new warning could not be noticed. Fixes #4. ## The `6.28` decision, measured A 96×72 `sample::sample` rendered with `smooth-diffuse`, FNV-1a over the RGBA output, before → after: | phase | before | after | |---|---|---| | 0.00 | `775eedb743d95ae3` | `775eedb743d95ae3` | | 0.13 | `c60e7a43f7c414fb` | `c60e7a43f7c414fb` | | 0.37 | `28455376d7e58966` | `28455376d7e58966` | | 0.50 | `a89a9984b5d87b9b` | `7188532671eaa0d3` | | 0.71 | `3f5c7b8d59ac181b` | `3f5c7b8d59ac181b` | | 0.99 | `1903ae281e599fcb` | `1903ae281e599fcb` | So every static render (`--render`, `--audit`, `--selftest`, the 1-bit fingerprints) is bit-identical: they render at phase 0. One animation frame changes — phase 0.5, the half turn, where 0.05 % of a turn decides which way a sub-pixel displacement rounds: 1396 of 6912 pixels differ, up to one row of shift. That is the hair the issue predicted, and it is the half turn where the wobble is supposed to be exactly inverted. ## The 143 warnings - 74 `field_reassign_with_default` (173 assignments) → the literal they were building field by field; 4 comparators → `sort_by_key` with `Reverse`; `chunks_exact(n)` → `as_chunks::<n>()`; needless borrows and casts, `if`s with two identical arms, `.err().expect()` → `expect_err`, a `Default` impl that is a derive, `Tab::EffectTab` → `Tab::Effect`. - `theme.rs`'s test module sat before other items and moved, unchanged, to the end of the file (the file's lines are otherwise identical apart from one `assert_eq!(…, true)` → `assert!`). - Kept with the reason next to them: `engine::adjust` (`#[allow(dead_code)]`, it is the single-colour path the LUT replaced) and `engine::cell_threshold` (`#[allow(clippy::too_many_arguments)]`, eight arguments that a struct would turn into a per-pixel allocation). - Deleted because nothing called them: `engine::bayer16`, `engine::build_lut`, `shapes_data::find`, `halftone::Screen::cells_per_side`, two unused test helpers. `fx::tile_ok` was a duplicate of what `tile_problem` checks inline, so `tile_problem` now asks it. - `shape::remove_band` had two arms that removed the same stop; they are one `if` with a comment saying why the index needs no second test. ## Checks Run on the branch tip `5e78b45` (the three commits are below): - [x] `cargo fmt --check` - [x] `cargo test --release` — 256 passed - [x] `opendither --audit` — 558 checks, 558 passed, 1 skipped - [x] `opendither --controls` — 62 checked, 0 failed - [x] `opendither --uitest` — 111 checks, 111 passed - [x] `opendither --selftest` — 456 renders, 0 failures - [x] `cargo clippy --all-targets -- -D warnings` — exit 0, debug and release The lint pass alone: `cargo clippy --all-targets` went from one `deny`-level error and 139 warnings to 0 and 0 (143 warning lines by clippy's own count, 88 of them duplicates of the same site). ## Not checked Nothing was cross-built for Windows; no `cfg(windows)` code was touched, but the release build in `README.md` › Release builds was not run. ## Notes for the reviewer - Three commits: the `6.28` decision (`fix(engine)`), the warning pass (`chore(clippy)`) and the two documentation lines (`docs`) — plus the `.git-blame-ignore-revs` entry for the pass. - The cleanup commit is in `.git-blame-ignore-revs`, so `git blame` looks through it (that file needs `git config blame.ignoreRevsFile .git-blame-ignore-revs`). - The suites have no row that pins clippy itself — there is no CI on this repository, so the gate is the line in `AGENTS.md` plus the reviewer. A CI job that runs the six commands would close that, and is more than this issue asks for.
`6.28` is TAU truncated by 0.05 %. Every other pattern in `glitch_pre`
multiplies the animation phase by `std::f32::consts::TAU`, so this one was an
approximation, not a deliberate value. Written out, the decision:
static renders and the `--selftest` fingerprints are bit-identical (they render
at phase 0), and so are the phases 0.13, 0.37, 0.71 and 0.99 of a 96x72 sample;
at phase 0.5 - the half turn, where the 0.05 % decides which way a sub-pixel
displacement rounds - 1396 of 6912 pixels change, up to one row of shift.

clippy::approx_constant is deny-by-default, so this was the only error that
stopped `cargo clippy --all-targets` from reporting anything at all.
`approx_constant` was deny-level, so clippy stopped there and the other 143
warnings were never looked at. What is left is cleared here, and none of it
changes behaviour — the 256 tests and the five suites below say so.

Mechanical, no decision in them:

- 74 `field_reassign_with_default` (173 assignments) became the `T { …,
  ..Default::default() }` literal they were setting up field by field.
- 4 comparators became `sort_by_key` with `Reverse`, which is the same order.
- `chunks_exact(n)` became `as_chunks::<n>()`, which reads the same bytes and
  drops the same remainder.
- `format!("{}", x)` on a `&str`, needless borrows and casts, `if`s with two
  identical arms, `.err().expect()` → `expect_err`, `or_else(|| match …)` → `or`,
  a `Default` impl that is a derive, `Tab::EffectTab` → `Tab::Effect` (a variant
  may not repeat its enum's name).
- `theme.rs`'s test module sat before other items; clippy wants the tests last,
  so it moved, unchanged, to the end of the file.
- `mod seed_tests` — see above; the file's lines are otherwise identical.

With a reason next to them:

- `engine::adjust` stays with `#[allow(dead_code)]`: the comment already said it
  is kept for a caller that wants a single colour.
- `engine::cell_threshold` keeps its eight arguments, `#[allow(
  too_many_arguments)]`: it is called once per pixel, so a struct would be
  built per pixel to be read for two fields.

Deleted, because nothing called them: `engine::bayer16`, `engine::build_lut`,
`shapes_data::find`, `halftone::Screen::cells_per_side` and two unused test
helpers. `fx::tile_ok` was the question `tile_problem` answers inline, so the
two now share it instead.
`cargo clippy --all-targets -- -D warnings` exits 0 on the tree now, so the two
files that list the checks a change has to pass say so, and say what to do with
a lint that is wrong for the code it fires on: silence it where it fires and
write the reason next to it.
The commit clears 143 warnings without changing behaviour, so a line that
survives it should blame the change that wrote it, not the lint pass.
ben changed title from chore: clippy is green on main — 6.28 decided, 143 warnings cleared to chore(clippy): make the lint gate exit 0, decide 6.28 2026-11-17 17:41:34 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin "chore/clippy-green:chore/clippy-green"
git switch "chore/clippy-green"
Sign in to join this conversation.
No description provided.