From abdf99cf8c9a3d2f2af609b253f0e046329c9e8f Mon Sep 17 00:00:00 2001 From: Chummy Date: Tue, 17 Feb 2026 16:33:10 +0800 Subject: [PATCH] chore(lint): extend low-risk clippy cleanup batch - normalize numeric literals (115_200) in hardware/peripheral config paths - remove test-only useless format! allocations in discord IDs - simplify closures and auto-deref in browser/http/rag/peripherals - keep behavior unchanged while reducing warning surface --- src/channels/discord.rs | 4 ++-- src/config/schema.rs | 8 ++++---- src/peripherals/mod.rs | 2 +- src/peripherals/serial.rs | 2 +- src/peripherals/uno_q_setup.rs | 2 +- src/rag/mod.rs | 4 +--- src/tools/browser.rs | 2 +- src/tools/http_request.rs | 2 +- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/channels/discord.rs b/src/channels/discord.rs index bdfb905..71b9892 100644 --- a/src/channels/discord.rs +++ b/src/channels/discord.rs @@ -723,8 +723,8 @@ mod tests { #[test] fn discord_message_id_different_message_different_id() { // Different message IDs produce different IDs - let id1 = format!("discord_123456789012345678"); - let id2 = format!("discord_987654321098765432"); + let id1 = "discord_123456789012345678".to_string(); + let id2 = "discord_987654321098765432".to_string(); assert_ne!(id1, id2); } diff --git a/src/config/schema.rs b/src/config/schema.rs index d0fcdbf..308f8e3 100644 --- a/src/config/schema.rs +++ b/src/config/schema.rs @@ -168,7 +168,7 @@ pub struct HardwareConfig { } fn default_baud_rate() -> u32 { - 115200 + 115_200 } impl HardwareConfig { @@ -436,7 +436,7 @@ fn default_peripheral_transport() -> String { } fn default_peripheral_baud() -> u32 { - 115200 + 115_200 } impl Default for PeripheralsConfig { @@ -2892,7 +2892,7 @@ default_temperature = 0.7 assert!(b.board.is_empty()); assert_eq!(b.transport, "serial"); assert!(b.path.is_none()); - assert_eq!(b.baud, 115200); + assert_eq!(b.baud, 115_200); } #[test] @@ -2903,7 +2903,7 @@ default_temperature = 0.7 board: "nucleo-f401re".into(), transport: "serial".into(), path: Some("/dev/ttyACM0".into()), - baud: 115200, + baud: 115_200, }], datasheet_dir: None, }; diff --git a/src/peripherals/mod.rs b/src/peripherals/mod.rs index 6084cab..982dc69 100644 --- a/src/peripherals/mod.rs +++ b/src/peripherals/mod.rs @@ -91,7 +91,7 @@ pub fn handle_command(cmd: crate::PeripheralCommands, config: &Config) -> Result board: board.clone(), transport: transport.to_string(), path: path_opt, - baud: 115200, + baud: 115_200, }); cfg.save()?; println!("Added {} at {}. Restart daemon to apply.", board, path); diff --git a/src/peripherals/serial.rs b/src/peripherals/serial.rs index ab40d71..05d0bae 100644 --- a/src/peripherals/serial.rs +++ b/src/peripherals/serial.rs @@ -76,7 +76,7 @@ impl SerialTransport { let mut port = self.port.lock().await; let resp = tokio::time::timeout( std::time::Duration::from_secs(SERIAL_TIMEOUT_SECS), - send_request(&mut *port, cmd, args), + send_request(&mut port, cmd, args), ) .await .map_err(|_| { diff --git a/src/peripherals/uno_q_setup.rs b/src/peripherals/uno_q_setup.rs index 3b7d114..424bc89 100644 --- a/src/peripherals/uno_q_setup.rs +++ b/src/peripherals/uno_q_setup.rs @@ -66,7 +66,7 @@ fn deploy_remote(host: &str, bridge_dir: &std::path::Path) -> Result<()> { "arduino-app-cli", "app", "start", - &format!("~/ArduinoApps/zeroclaw-uno-q-bridge"), + "~/ArduinoApps/zeroclaw-uno-q-bridge", ]) .status() .context("arduino-app-cli start failed")?; diff --git a/src/rag/mod.rs b/src/rag/mod.rs index cc98c5a..19254f8 100644 --- a/src/rag/mod.rs +++ b/src/rag/mod.rs @@ -233,9 +233,7 @@ impl HardwareRag { if let Some(aliases) = self.pin_aliases.get(board) { for (alias, pin) in aliases { let alias_words: Vec<&str> = alias.split('_').collect(); - let matches = query_words - .iter() - .any(|qw| alias_words.iter().any(|aw| *aw == *qw)) + let matches = query_words.iter().any(|qw| alias_words.contains(qw)) || query_lower.contains(&alias.replace('_', " ")); if matches { lines.push(format!("{board}: {alias} = pin {pin}")); diff --git a/src/tools/browser.rs b/src/tools/browser.rs index d138f09..fe3be26 100644 --- a/src/tools/browser.rs +++ b/src/tools/browser.rs @@ -2023,7 +2023,7 @@ fn is_non_global_v6(v6: std::net::Ipv6Addr) -> bool { // Link-local (fe80::/10) || (segs[0] & 0xffc0) == 0xfe80 // IPv4-mapped addresses - || v6.to_ipv4_mapped().is_some_and(|v4| is_non_global_v4(v4)) + || v6.to_ipv4_mapped().is_some_and(is_non_global_v4) } fn host_matches_allowlist(host: &str, allowed: &[String]) -> bool { diff --git a/src/tools/http_request.rs b/src/tools/http_request.rs index 450bde5..0701f95 100644 --- a/src/tools/http_request.rs +++ b/src/tools/http_request.rs @@ -428,7 +428,7 @@ fn is_non_global_v6(v6: std::net::Ipv6Addr) -> bool { || (segs[0] & 0xfe00) == 0xfc00 // Unique-local (fc00::/7) || (segs[0] & 0xffc0) == 0xfe80 // Link-local (fe80::/10) || (segs[0] == 0x2001 && segs[1] == 0x0db8) // Documentation (2001:db8::/32) - || v6.to_ipv4_mapped().is_some_and(|v4| is_non_global_v4(v4)) + || v6.to_ipv4_mapped().is_some_and(is_non_global_v4) } #[cfg(test)]