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
This commit is contained in:
Chummy 2026-02-17 16:33:10 +08:00
parent 4413790859
commit abdf99cf8c
8 changed files with 12 additions and 14 deletions

View file

@ -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);
}

View file

@ -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,
};

View file

@ -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);

View file

@ -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(|_| {

View file

@ -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")?;

View file

@ -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}"));

View file

@ -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 {

View file

@ -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)]