Skip to content

Adopt rustfmt and check formatting in CI - #17

Merged
schreck61 merged 3 commits into
mainfrom
adopt-rustfmt
Nov 11, 2026
Merged

schreck61 merged 3 commits into
mainfrom
adopt-rustfmt

Conversation

@schreck61

Copy link
Copy Markdown
Owner

What

  • rustfmt.toml: only settings that stable rustfmt supports. Lines may run to 110 characters, and use_small_heuristics = "Max" keeps a short expression on one line whenever it fits, so the layout stays close to what it was.
  • One formatting commit: cargo fmt on the crate and the fuzz target, nothing else. It changes 38 of the 45 Rust files (+1,889/−455 lines), mostly by splitting long signatures, calls, conditions and method chains across lines, and it sorts a few imports. The code had no hand-aligned tables, so nothing needed #[rustfmt::skip].
  • CI: the Clippy job runs cargo fmt --check on the crate and the fuzz target before linting. Clippy is already a required check, so a pull request that isn't formatted can't merge, and the ruleset stays as it is.
  • Docs: CONTRIBUTING.md names the coding standard (the Rust Style Guide as rustfmt applies it, and Clippy's default lints) and lists cargo fmt --all --check with the other checks. The pull request template, GOVERNANCE.md and the CI table in docs/architecture.md mention the new step.

Once this merges, a follow-up adds the formatting commit to .git-blame-ignore-revs, so that git blame and GitHub's blame view skip it. It can't be part of this pull request, because a rebase merge gives the commit a new hash.

Why

Nothing checked the code's layout, and a contributor who runs cargo fmt out of habit would have reformatted whole files. This also meets the coding_standards and coding_standards_enforced criteria of the OpenSSF Best Practices silver badge.

Testing

  • cargo fmt --all --check and cargo fmt --manifest-path fuzz/Cargo.toml --check are clean. The second also works without fuzz/Cargo.lock, which the Clippy job doesn't have.
  • cargo build --locked --release --all-targets and cargo test --locked --release pass.
  • cargo clippy --locked --release --all-targets -- -D warnings and its wasm32 counterpart pass.
  • The reformatted fuzz target wasn't compiled locally; CI's fuzz job builds it.

Use only settings that stable rustfmt supports: lines up to 110
characters, and use_small_heuristics = "Max" so that a short expression
stays on one line whenever it fits. Together they keep the layout close
to that of the existing code.

Signed-off-by: Jim Schreckengast <schreck@gmail.com>
Run cargo fmt on the crate and on the fuzz target with the settings in
rustfmt.toml. Only layout and the order of imports change.

Signed-off-by: Jim Schreckengast <schreck@gmail.com>
The Clippy job now runs cargo fmt --check on the crate and the fuzz
target before linting, so a pull request that isn't formatted fails a
required check. CONTRIBUTING.md names the coding standard: the Rust Style
Guide as rustfmt applies it, and Clippy's default lints. The pull request
checklist asks for cargo fmt, and GOVERNANCE.md and docs/architecture.md
describe the new step.

Signed-off-by: Jim Schreckengast <schreck@gmail.com>
@schreck61
schreck61 enabled auto-merge (rebase) November 11, 2026 14:39
@schreck61
schreck61 merged commit 551d82a into main Nov 11, 2026
12 checks passed
schreck61 added a commit that referenced this pull request Nov 11, 2026
List the formatting commit from #17 in .git-blame-ignore-revs, which
GitHub's blame view reads, and say in CONTRIBUTING.md how to make git
blame skip it locally.

Signed-off-by: Jim Schreckengast <schreck@gmail.com>
@schreck61
schreck61 deleted the adopt-rustfmt branch November 11, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant