chore: silence clippy 1.94 errors so CI -D warnings stays green #105

Merged
David merged 2 commits from chore/clippy-1.94-cleanup into main 2026-05-15 02:26:47 +02:00
Owner

Summary

Closes the gap that made the CI clippy step red while local just check passed green: CI runs clippy on Rust 1.94 with -D warnings; the local ./dev/cargo wrapper is still pinned to rust:1.88-slim-bookworm and the justfile clippy recipes do not pass -- -D warnings. Rust 1.94's clippy ships lints that did not exist in 1.88 (manual_repeat_n, refreshed should_implement_trait matching, etc.) and the strict-flags difference promotes the rest of the existing warnings to errors. This PR fixes the source side; a follow-up will sync the local image + recipes so the next drift surfaces locally before push.

What changed

Library

  • bg.rs, views/room.rs: std::iter::repeat("?").take(n) -> std::iter::repeat_n("?", n).
  • views/room.rs::excerpt_for_quote: collapse the consecutive \r/\n str::replace into replace(['\r','\n'], " ") and switch the manual count accumulator to chars().enumerate().
  • ws/hub.rs::Hub: add impl Default for Hub (the inherent new() is otherwise the sole constructor).
  • models/enclave.rs::EnclaveRole: replace the inherent from_str with impl std::str::FromStr for EnclaveRole. Callers in db/enclave.rs and tests/db_enclave.rs pick up a use std::str::FromStr; so the existing EnclaveRole::from_str(...) call shape still resolves.
  • routes/email_verification.rs, routes/password_reset.rs: drop the inner #![cfg(feature = "standalone")]. The outer #[cfg(feature = "standalone")] mod ...; in routes/mod.rs already gates compilation.
  • Build scripts and every other format!("...{}", x) / println!("...{}", x) site: inlined into the captured-identifier form via cargo clippy --fix.

Tests

  • tests/db_uploads.rs: map.get(&m3).is_none() -> !map.contains_key(&m3).
  • tests/routes_broadcast_mentions.rs::TestApp.push_client: field-level #[allow(dead_code)] (some test cases swap in a counting mock and observe it; not every binary in the file reads it).
  • tests/routes_enclave.rs, tests/db_dm_mute.rs, tests/db_mentions.rs: residual inlined-format-args and &val -> val from cargo clippy --fix --all-targets.

Test plan

  • ./dev/cargo clippy -p lets-chat-server --all-targets -- -D warnings is clean.
  • ./dev/cargo clippy -p lets-chat-server --no-default-features --features saas --all-targets -- -D warnings is clean.
  • ./dev/cargo-desktop clippy -p lets-chat-desktop -- -D warnings is clean.
  • ./dev/cargo fmt --check is clean.
  • ./dev/cargo test -p lets-chat-server --no-run compiles every test binary.
  • CI: the next push to this branch goes clippy-green under the strict-flags runner.

A follow-up PR will bump ./dev/cargo to rust:1.94-slim-bookworm and add -- -D warnings to the justfile clippy recipes so this kind of drift surfaces locally before CI catches it.

## Summary Closes the gap that made the CI clippy step red while local `just check` passed green: CI runs clippy on Rust 1.94 with `-D warnings`; the local `./dev/cargo` wrapper is still pinned to `rust:1.88-slim-bookworm` and the justfile clippy recipes do not pass `-- -D warnings`. Rust 1.94's clippy ships lints that did not exist in 1.88 (`manual_repeat_n`, refreshed `should_implement_trait` matching, etc.) and the strict-flags difference promotes the rest of the existing warnings to errors. This PR fixes the source side; a follow-up will sync the local image + recipes so the next drift surfaces locally before push. ## What changed ### Library - `bg.rs`, `views/room.rs`: `std::iter::repeat("?").take(n)` -> `std::iter::repeat_n("?", n)`. - `views/room.rs::excerpt_for_quote`: collapse the consecutive `\r`/`\n` `str::replace` into `replace(['\r','\n'], " ")` and switch the manual `count` accumulator to `chars().enumerate()`. - `ws/hub.rs::Hub`: add `impl Default for Hub` (the inherent `new()` is otherwise the sole constructor). - `models/enclave.rs::EnclaveRole`: replace the inherent `from_str` with `impl std::str::FromStr for EnclaveRole`. Callers in `db/enclave.rs` and `tests/db_enclave.rs` pick up a `use std::str::FromStr;` so the existing `EnclaveRole::from_str(...)` call shape still resolves. - `routes/email_verification.rs`, `routes/password_reset.rs`: drop the inner `#![cfg(feature = "standalone")]`. The outer `#[cfg(feature = "standalone")] mod ...;` in `routes/mod.rs` already gates compilation. - Build scripts and every other `format!("...{}", x)` / `println!("...{}", x)` site: inlined into the captured-identifier form via `cargo clippy --fix`. ### Tests - `tests/db_uploads.rs`: `map.get(&m3).is_none()` -> `!map.contains_key(&m3)`. - `tests/routes_broadcast_mentions.rs::TestApp.push_client`: field-level `#[allow(dead_code)]` (some test cases swap in a counting mock and observe it; not every binary in the file reads it). - `tests/routes_enclave.rs`, `tests/db_dm_mute.rs`, `tests/db_mentions.rs`: residual inlined-format-args and `&val` -> `val` from `cargo clippy --fix --all-targets`. ## Test plan - [x] `./dev/cargo clippy -p lets-chat-server --all-targets -- -D warnings` is clean. - [x] `./dev/cargo clippy -p lets-chat-server --no-default-features --features saas --all-targets -- -D warnings` is clean. - [x] `./dev/cargo-desktop clippy -p lets-chat-desktop -- -D warnings` is clean. - [x] `./dev/cargo fmt --check` is clean. - [x] `./dev/cargo test -p lets-chat-server --no-run` compiles every test binary. - [ ] CI: the next push to this branch goes clippy-green under the strict-flags runner. A follow-up PR will bump `./dev/cargo` to `rust:1.94-slim-bookworm` and add `-- -D warnings` to the justfile clippy recipes so this kind of drift surfaces locally before CI catches it.
chore: silence clippy 1.94 errors so CI -D warnings stays green
Some checks failed
Check / clippy + fmt + tests (pull_request) Failing after 27s
9f2f02f76f
CI runs clippy on Rust 1.94 with `-D warnings`, which surfaces a handful of lints that local `just check` (currently pinned to Rust 1.88, no `-D warnings`) only reports as informational warnings. Bringing the source in line with both layers:

Library
- `bg.rs`, `views/room.rs`: `std::iter::repeat("?").take(n)` -> `std::iter::repeat_n("?", n)` (clippy::manual_repeat_n, added in 1.82).
- `views/room.rs::excerpt_for_quote`: collapse two consecutive `str::replace` calls into `replace(['\\r','\\n'], " ")` and switch the manual `count` accumulator to `chars().enumerate()` (clippy::collapsible_str_replace, clippy::explicit_counter_loop).
- `ws/hub.rs::Hub`: add `impl Default for Hub` so the inherent `new()` is not flagged as the sole construction path (clippy::new_without_default).
- `models/enclave.rs::EnclaveRole`: replace the inherent `from_str` with a proper `impl FromStr for EnclaveRole` (clippy::should_implement_trait). Callers in `db/enclave.rs` and `tests/db_enclave.rs` get a `use std::str::FromStr;` so the existing `EnclaveRole::from_str(...)` call sites resolve unchanged.
- `routes/email_verification.rs`, `routes/password_reset.rs`: drop the inner `#![cfg(feature = "standalone")]`. The outer `#[cfg(feature = "standalone")] mod foo;` in `routes/mod.rs` already gates compilation, so the file-scope attribute is redundant (clippy::duplicated_attributes).
- Build scripts (`server/build.rs`, `desktop/build.rs`) and the rest of the lib + tests: inlined every `format!("...{}", x)` / `println!("...{}", x)` into the captured-identifier form `{x}` (clippy::uninlined_format_args, fully mechanical, applied via `cargo clippy --fix`).

Tests
- `tests/db_uploads.rs`: `map.get(&m3).is_none()` -> `!map.contains_key(&m3)` (clippy::redundant_pattern_matching variant).
- `tests/routes_broadcast_mentions.rs`: `TestApp.push_client` is set by some test cases and read by others but not by every binary in this file, so add a field-level `#[allow(dead_code)]` rather than gating every individual test with `#[cfg(...)]` (clippy::dead_code in test binaries).
- `tests/routes_enclave.rs`, `tests/db_dm_mute.rs`, `tests/db_mentions.rs`: residual inlined-format-args and `&val` -> `val` cleanups picked up by `cargo clippy --fix --all-targets`.

Verification
- `./dev/cargo clippy -p lets-chat-server --all-targets -- -D warnings` is clean.
- `./dev/cargo clippy -p lets-chat-server --no-default-features --features saas --all-targets -- -D warnings` is clean.
- `./dev/cargo-desktop clippy -p lets-chat-desktop -- -D warnings` is clean.
- `./dev/cargo fmt --check` is clean.
- `./dev/cargo test -p lets-chat-server --no-run` compiles every test binary.

The `just check` recipe is intentionally not changed in this commit so the diff stays scoped to source fixes; bumping the local Rust image to 1.94 and adding `-- -D warnings` to the clippy recipes (so the local check matches what CI enforces) lands as a separate change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merge branch 'main' into chore/clippy-1.94-cleanup
Some checks failed
Check / clippy + fmt + tests (pull_request) Failing after 14s
4c25156aba
David merged commit d4f42ab8fd into main 2026-05-15 02:26:47 +02:00
David deleted branch chore/clippy-1.94-cleanup 2026-05-15 02:26:47 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/lets-chat!105
No description provided.