From 7a9cf5b81266a141870b2461e50f7d25ba14c2c0 Mon Sep 17 00:00:00 2001 From: Levi Neuwirth Date: Sat, 1 Aug 2026 09:38:36 -0400 Subject: [PATCH] fix(lint): make the crdt targets pass clippy for the first time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `cargo clippy --workspace --all-targets --features crdt -- -D warnings` has never passed on main. The standing gate list runs clippy without `crdt`, so these lints have never been enforced, and any CI job that compiles the crdt targets would be red on arrival. This is framing §7 step 1: nothing else in the lane is testable until it lands. Eight findings across four files, none behavioral: src/daemon.rs useless_conversion (u64) src/daemon.rs missing doc backticks src/daemon.rs too_many_lines (112/100) tests/auto_indent_crdt_acceptance.rs missing doc backticks tests/bottom_panel_stage2b_gpu_acceptance too_many_lines (104/100) tests/vterm_stage3_acceptance.rs too_many_lines (122/100) tests/vterm_stage3_acceptance.rs too_many_lines (132/100) tests/vterm_stage3_acceptance.rs redundant `continue` --keep-going is what made this an inventory rather than a lower bound. docs/active-work.md recorded seven findings at 74301d1 and correctly warned they were "a lower bound, not an inventory" because clippy abandons remaining targets once one fails. With --keep-going the set is complete, and it differs from the ledger's in both directions: the `unneeded mut` at src/daemon.rs:4965 is gone (fixed incidentally by later work), a finding in bottom_panel_stage2b_gpu_acceptance.rs is new, and every src/daemon.rs line number had moved. A stale lint inventory is worse than none — it invites fixing lines that no longer exist. The four too_many_lines findings are silenced with a reason rather than refactored. Refactoring a test body to satisfy a lint that has never run would be a behavioral change riding a CI-configuration lane, and the codebase already has ~20 `#[allow(clippy::too_many_lines)]` sites, the best of them carrying `reason =`. Each reason states why the scenario is one test: the GPU acceptances exist specifically to prove a real daemon, a real PTY and real wgpu fit together, which splitting would hide. The redundant `continue` needed care. Replacing it with `Err(_) => {}` traded the lint for `single_match` — the match then destructured one pattern. Rewritten as an edition-2024 let-chain, which drops both without changing semantics: an unreadable message still falls through to the next loop iteration. Verified: clippy green with and without `crdt` (the second confirming no regression to the enforced gate), fmt, diff-check, --lib --features crdt 2081 passed, and the three touched suites green — vterm_stage3 at 9/9 in 4.34s rather than 0.17s, so a37 really ran rather than reporting ok on a missing binary. Co-Authored-By: Claude Opus 5 (1M context) --- src/daemon.rs | 9 ++++++--- tests/auto_indent_crdt_acceptance.rs | 2 +- tests/bottom_panel_stage2b_gpu_acceptance.rs | 4 ++++ tests/vterm_stage3_acceptance.rs | 19 ++++++++++++------- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/daemon.rs b/src/daemon.rs index 02ade4d..9c4dd76 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -4461,8 +4461,7 @@ mod tests { .expect("export snapshot") }; let peer = loro::LoroDoc::new(); - peer.set_peer_id(u64::from(FrontendId::LOCAL.0)) - .expect("set peer id"); + peer.set_peer_id(FrontendId::LOCAL.0).expect("set peer id"); peer.import(&snapshot_bytes).expect("import snapshot"); let v_before = peer.oplog_vv(); peer.get_text("body").insert(0, "x").expect("peer insert"); @@ -4541,13 +4540,17 @@ mod tests { } /// Kill ring Q#KR2 — GPU typing arrives here without touching - /// dispatch_key, so it must update the source frontend's command + /// `dispatch_key`, so it must update the source frontend's command /// boundary or `C-k x C-k` on the GPU would append across the typed /// character. A single-codepoint insert classifies as /// `buffer.self-insert` (the input-origin signal for signature /// help); anything else breaks the chain outright. #[cfg(feature = "crdt")] #[test] + #[allow( + clippy::too_many_lines, + reason = "one end-to-end classification scenario per kill-chain case" + )] fn handle_remote_crdt_op_classifies_typed_input_and_ends_kill_chains() { use crate::editor::EditorState; use crate::protocol::FrontendId; diff --git a/tests/auto_indent_crdt_acceptance.rs b/tests/auto_indent_crdt_acceptance.rs index 718f927..462ce98 100644 --- a/tests/auto_indent_crdt_acceptance.rs +++ b/tests/auto_indent_crdt_acceptance.rs @@ -39,7 +39,7 @@ fn read_initial_snapshot( } /// Mutate the local replica, export the delta, and ship it as an -/// optimistic `FrontendEvent::CrdtOp` (the m10_11 idiom). +/// optimistic `FrontendEvent::CrdtOp` (the `m10_11` idiom). fn send_optimistic_op_from( stream: &mut std::os::unix::net::UnixStream, replica: &CrdtState, diff --git a/tests/bottom_panel_stage2b_gpu_acceptance.rs b/tests/bottom_panel_stage2b_gpu_acceptance.rs index 70814d3..e11493b 100644 --- a/tests/bottom_panel_stage2b_gpu_acceptance.rs +++ b/tests/bottom_panel_stage2b_gpu_acceptance.rs @@ -506,6 +506,10 @@ fn decode_hex(encoded: &str) -> String { /// out its safety deadline cannot read as a pass. #[cfg(feature = "crdt")] #[test] +#[allow( + clippy::too_many_lines, + reason = "one real-daemon/real-PTY/real-wgpu scenario; splitting it would hide the fit it exists to prove" +)] fn a54_real_daemon_real_pty_and_headless_gpu_render_one_panel_hosted_terminal() { use std::path::{Path, PathBuf}; diff --git a/tests/vterm_stage3_acceptance.rs b/tests/vterm_stage3_acceptance.rs index c415abf..afa4d83 100644 --- a/tests/vterm_stage3_acceptance.rs +++ b/tests/vterm_stage3_acceptance.rs @@ -634,6 +634,10 @@ pmacs.keymap.bind { scope = "global", sequence = "C-M-t", command = "vterm-probe /// prove nothing about the three fitting together. #[cfg(feature = "crdt")] #[test] +#[allow( + clippy::too_many_lines, + reason = "one real-daemon/real-PTY/real-wgpu scenario; a decoded-message fixture is deliberately not a substitute" +)] fn a37_real_daemon_real_pty_and_headless_gpu_render_one_terminal_session() { use std::path::{Path, PathBuf}; @@ -813,6 +817,10 @@ fn a37_real_daemon_real_pty_and_headless_gpu_render_one_terminal_session() { /// property of the dispatcher loop, not of any function it calls. #[cfg(feature = "crdt")] #[test] +#[allow( + clippy::too_many_lines, + reason = "real daemon, real wire, two real frontends in one dispatcher-loop scenario" +)] fn terminal_mode_keeps_reporting_presence_so_peers_drop_the_stale_caret() { use pmacs::protocol::{ AttachRequest, FrontendCapabilities, Hello, Key, KeyEvent, PROTOCOL_VERSION, @@ -857,13 +865,10 @@ fn terminal_mode_keeps_reporting_presence_so_peers_drop_the_stale_caret() { ) -> T { let deadline = Instant::now() + Duration::from_secs(20); while Instant::now() < deadline { - match read_message::(stream) { - Ok(msg) => { - if let Some(found) = want(&msg) { - return found; - } - } - Err(_) => continue, + if let Ok(msg) = read_message::(stream) + && let Some(found) = want(&msg) + { + return found; } } panic!("timed out waiting for {what}");