Adopt rustfmt and clean up clippy warnings
Formats the whole backend to rustfmt defaults and fixes all 23 outstanding clippy warnings (collapsible ifs, clone-to-slice-ref, type-complexity, single-arm match, unnecessary is_none check), then wires cargo fmt --check and -D warnings into make lint so both stay enforced going forward. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TeyhRfMYjMditek6geDRoQ
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
2cc8ac8138
commit
c3108677ce
@@ -1,34 +0,0 @@
|
||||
# 094 — Adopt rustfmt and format the codebase
|
||||
|
||||
## Summary
|
||||
|
||||
The Rust backend has no `rustfmt.toml` and isn't currently formatted
|
||||
to rustfmt's defaults: `cargo fmt -- --check` exits non-zero, reporting
|
||||
diffs across 24 files (352 diff hunks total).
|
||||
|
||||
## Where
|
||||
|
||||
- No `rustfmt.toml` / `.rustfmt.toml` exists at the repo root.
|
||||
- `cargo fmt -- --check` reports diffs in `src/api/{dto,mcp_server,mod}.rs`,
|
||||
`src/cli/{mod,sessions}.rs`, `src/config/{mod,profile}.rs`, and most
|
||||
of `src/engine/**` (`alerts.rs`, `data_value.rs`, `filter_datetime.rs`,
|
||||
`filter_parser.rs`, `ingest.rs`, `logfmt.rs`, `message.rs`, `mod.rs`,
|
||||
`promql.rs`, `rate.rs`, `snapshot/{filter,metrics,mod,params,query,sort}.rs`,
|
||||
`tests.rs`). Heaviest: `src/engine/snapshot/mod.rs` (~65 hunks),
|
||||
`src/config/profile.rs` (~38), `src/api/mod.rs` (~35),
|
||||
`src/engine/alerts.rs` (~28).
|
||||
- `Makefile:26` (`lint-be`) currently only runs `cargo clippy
|
||||
--all-targets` — no `cargo fmt --check` step.
|
||||
|
||||
## Scope
|
||||
|
||||
- Add a `rustfmt.toml` if any defaults should be overridden (otherwise
|
||||
an empty/absent file is fine and rustfmt defaults apply — decide
|
||||
whether to keep the file empty for documentation purposes or omit
|
||||
it).
|
||||
- Run `cargo fmt` across the whole `src/` tree as a single,
|
||||
non-functional formatting commit (don't mix with logic changes, to
|
||||
keep the diff reviewable and `git blame`-friendly).
|
||||
- Add a `cargo fmt --check` step to `make lint` (or a new `make
|
||||
fmt-check` wired into CI) so future changes can't drift out of
|
||||
format again.
|
||||
@@ -1,41 +0,0 @@
|
||||
# 095 — Resolve clippy warnings and make lint enforce a clean run
|
||||
|
||||
## Summary
|
||||
|
||||
`make lint`'s backend target runs `cargo clippy --all-targets` with no
|
||||
`-D warnings` (or equivalent), so clippy warnings accumulate silently
|
||||
instead of failing the lint step. There are currently 23 unique
|
||||
warnings across 5 lint categories.
|
||||
|
||||
## Where
|
||||
|
||||
- `Makefile:26` (`lint-be:`) — `cargo clippy --all-targets`, no denial
|
||||
flag.
|
||||
- `cargo clippy --all-targets` currently reports, by lint:
|
||||
- `clippy::cloned_ref_to_slice_refs` — 10 occurrences, mostly in
|
||||
`src/engine/alerts.rs` test code (e.g. around lines 469, 472, 493,
|
||||
534).
|
||||
- `clippy::collapsible_if` — 8 occurrences, concentrated in
|
||||
`src/engine/snapshot/mod.rs` (lines 608, 940, 961) and
|
||||
`src/engine/alerts.rs` (around lines 510, 512).
|
||||
- `clippy::type_complexity` — 3 occurrences.
|
||||
- `clippy::single_match` — 1 occurrence.
|
||||
- `clippy::unnecessary_get_then_check` — 1 occurrence,
|
||||
`src/engine/tests.rs:2234`
|
||||
(`entries[1].params.get("level").is_none()`).
|
||||
|
||||
## Scope
|
||||
|
||||
- Fix all 23 current warnings (mechanical for most: `from_ref` for the
|
||||
slice-ref clone cases, collapsing nested `if`s, `is_none()` →
|
||||
`!contains_key`/`get().is_none()` equivalent simplification per
|
||||
clippy's suggestion, breaking up the complex types clippy flags or
|
||||
adding a type alias, converting the single-arm `match` to `if let`).
|
||||
- Once clean, change `Makefile:26` to deny warnings (e.g. `cargo
|
||||
clippy --all-targets -- -D warnings`) so the target fails on any
|
||||
future regression instead of just printing them.
|
||||
- Don't add blanket `#[allow(...)]`s to silence these — fix the
|
||||
underlying code per clippy's suggestion, matching the existing
|
||||
`#[allow(dead_code)]` uses elsewhere in the codebase which are for
|
||||
genuinely-unused-for-now items, not a precedent for suppressing
|
||||
active lints.
|
||||
Reference in New Issue
Block a user