Feat/add rustfmt clippy ci - #838
Open
AndyGauge wants to merge 1 commit into
Open
Conversation
…own code
Adds a CI lint job running `cargo fmt --all --check`, `cargo clippy
--workspace --all-targets -D warnings`, and a new `cargo xtask fmt-md
--check` for the code blocks written inline in the book's markdown.
Tests, spellcheck, and link checking stay in their existing workflows.
The skeptic-tested examples live inside `src/**/*.md`, so `cargo fmt`
never sees them. `xtask/src/fmt_md.rs` extracts each block, runs rustfmt
at the edition named by the fence, and rewrites the markdown, preserving
the file's existing line endings. It skips `{{#include}}` blocks (already
covered by `cargo fmt --all`), `ignore` blocks, and blocks using skeptic
`# ` hidden lines -- rustfmt reflows long lines, which would move code
across the hidden/visible boundary and silently change what readers see.
Formatting the workspace shifted line numbers that three `{{#include}}`
anchors depend on, so those were recomputed.
Clippy findings fixed rather than suppressed:
- web: drop a no-op `.into_iter()` and use `.next()` over `.nth(0)`
- xtask: `io::Error::other` in place of `io::Error::new(Other, _)`
- heapless_alloc: `3.14` was an arbitrary sensor reading, not PI, so
use a value that reads as a real measurement
Two lints are allowed per-crate where the example is the point:
`manual_map` in no_panic (the doc comment teaches exhaustive matching)
and `result_large_err` in figment (`figment::Error` is 208 bytes by
upstream design).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
AndyGauge
force-pushed
the
feat/add-rustfmt-clippy-ci
branch
from
August 24, 2026 21:58
221da33 to
3b6d5ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #837
Runs rustfmt and clippy in CI so the project's formatting expectations are
enforced automatically, instead of maintainers pointing them out by hand in
review (as in #836).
What runs in CI
A new
CIworkflow with a singlelintjob:Tests, spellcheck, and link checking stay where they already live
(
mdbook-test.yml,spellcheck.yml,check-links.yml) rather than beingduplicated here.
Formatting the inline markdown examples
The skeptic-tested examples are written directly inside
src/**/*.md, socargo fmtnever sees them.cargo xtask fmt-md(new,xtask/src/fmt_md.rs) extracts each fenced block, runs rustfmt at theedition named by the fence, and writes the result back — preserving the
file's existing line endings, since part of the book is checked in as CRLF.
--checkreports instead of rewriting.Of 283 blocks scanned, 126 were reformatted and 66 skipped:
{{#include}}of a workspace crate — already covered bycargo fmt --allignoreblocks — not compiled by skeptic, need not be valid Rust#hidden linesThe hidden-line blocks are left for a human on purpose. rustfmt reflows long
lines, so a hidden line that gets split would keep its
#marker on only onefragment — silently unhiding code in the published book.
fmt-mdreports themby name rather than guessing.
Formatting the workspace shifted line numbers that three
{{#include ...rs::N}}anchors depend on, so those were recomputed (
actor_pattern168→163,reload54→57,
exif23→29) and the rendered HTML checked to confirm each block stillends at
main's closing brace.Clippy findings
Fixed rather than suppressed:
crates/web/src/links.rs— drop a no-op.into_iter()crates/web/src/broken.rs—Iterator::nextover.nth(0)xtask/src/tests.rs—io::Error::otherin place ofio::Error::new(ErrorKind::Other, _)heapless_alloc.rs—3.14was an arbitrary sensor reading, not π, so it nowuses a value that reads as a real measurement
Two are allowed per-crate, where the flagged code is the example:
manual_mapinno_panic— the doc comment teaches exhaustively handlingevery path, which is what the spelled-out
matchshowsresult_large_errinfigment—figment::Erroris 208 bytes by upstreamdesign, and boxing it would only obscure the example's error handling
Also
Makefilegainsfmt,fmt-check, andlinttargets;CLAUDE.mddocumentscargo xtask fmt-md.