From 03f8786d2464043de1dc25d8b8fca412632b8ccc Mon Sep 17 00:00:00 2001 From: Riz Ashraf Date: Fri, 9 Oct 2026 01:06:30 +0100 Subject: [PATCH] chore: resolve clippy warnings for pre-push audit --- nvim-core/src/lib.rs | 5 +---- server/src/api/ws.rs | 25 +++++++++++-------------- server/src/lib.rs | 9 +++++---- server/src/router.rs | 2 +- server/src/state.rs | 3 +-- server/tests/image_test.rs | 3 +-- server/tests/parity_test.rs | 11 +++++++---- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/nvim-core/src/lib.rs b/nvim-core/src/lib.rs index d9d77fb..8d879de 100644 --- a/nvim-core/src/lib.rs +++ b/nvim-core/src/lib.rs @@ -2551,10 +2551,7 @@ mod tests { rmpv_to_json(&rmpv::Value::Integer(42.into())), serde_json::json!(42) ); - assert_eq!( - rmpv_to_json(&rmpv::Value::F64(3.14)), - serde_json::json!(3.14) - ); + assert_eq!(rmpv_to_json(&rmpv::Value::F64(3.5)), serde_json::json!(3.5)); assert_eq!( rmpv_to_json(&rmpv::Value::String("hello".into())), serde_json::json!("hello") diff --git a/server/src/api/ws.rs b/server/src/api/ws.rs index 1f8f986..aae121c 100644 --- a/server/src/api/ws.rs +++ b/server/src/api/ws.rs @@ -295,20 +295,17 @@ mod tests { .iter() .filter_map(|act_val| { if act_val["category"] == "TASK_EVENT" { - if let Some(details_str) = act_val["details"].as_str() { - if let Ok(event_val) = - serde_json::from_str::(details_str) - { - return Some( - serde_json::json!({ - "jsonrpc": "2.0", - "method": "notifications/task/completed", - "params": event_val - }) - .to_string(), - ); - } - } + let details_str = act_val["details"].as_str()?; + let event_val = + serde_json::from_str::(details_str).ok()?; + return Some( + serde_json::json!({ + "jsonrpc": "2.0", + "method": "notifications/task/completed", + "params": event_val + }) + .to_string(), + ); } None }) diff --git a/server/src/lib.rs b/server/src/lib.rs index 4b25c3d..3bf43cc 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -808,7 +808,7 @@ mod tests { #[test] fn test_cli_parsing_default() { - let cli = Cli::try_parse_from(&["mcp-memory-server"]).unwrap(); + let cli = Cli::try_parse_from(["mcp-memory-server"]).unwrap(); assert!(cli.command.is_none()); assert!(!cli.exit); assert!(!cli.restart); @@ -816,7 +816,7 @@ mod tests { #[test] fn test_cli_parsing_exit_and_target() { - let cli = Cli::try_parse_from(&[ + let cli = Cli::try_parse_from([ "mcp-memory-server", "--exit", "--target", @@ -829,7 +829,7 @@ mod tests { #[test] fn test_cli_parsing_gate_set() { - let cli = Cli::try_parse_from(&[ + let cli = Cli::try_parse_from([ "mcp-memory-server", "gate", "set", @@ -865,7 +865,7 @@ mod tests { #[test] fn test_cli_parsing_gate_verify() { - let cli = Cli::try_parse_from(&[ + let cli = Cli::try_parse_from([ "mcp-memory-server", "gate", "verify", @@ -930,6 +930,7 @@ mod tests { } #[tokio::test] + #[allow(clippy::await_holding_lock)] async fn test_run_server_graceful_shutdown() { let _lock = ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner()); let temp_dir = tempfile::tempdir().unwrap(); diff --git a/server/src/router.rs b/server/src/router.rs index 9e1f8e7..b79453f 100644 --- a/server/src/router.rs +++ b/server/src/router.rs @@ -1398,7 +1398,7 @@ mod tests { let handler = MemoryHandler::new(state); // 1. Verify invalid LLM requests fail gracefully with isError: true or structured response - for (tool_name, _tool) in &handler.tools { + for tool_name in handler.tools.keys() { let invalid_req = json!({ "jsonrpc": "2.0", "id": 200, diff --git a/server/src/state.rs b/server/src/state.rs index c8464e8..d11e878 100644 --- a/server/src/state.rs +++ b/server/src/state.rs @@ -1,5 +1,6 @@ use crate::models::*; use crate::search::MemoryIndex; +pub use crate::search::{SearchResult as UnifiedSearchResult, SearchService}; use crate::store::Store; use std::collections::HashMap; use std::path::PathBuf; @@ -575,5 +576,3 @@ mod tests { assert!(activities_updated[0].timestamp >= activities_updated[1].timestamp); } } - -pub use crate::search::{SearchResult as UnifiedSearchResult, SearchService}; diff --git a/server/tests/image_test.rs b/server/tests/image_test.rs index 42c0853..694b87e 100644 --- a/server/tests/image_test.rs +++ b/server/tests/image_test.rs @@ -1,7 +1,6 @@ -use image::DynamicImage; #[test] fn test_img() { let mut img = image::DynamicImage::new_rgb8(10, 10); img.invert(); - let img2 = img.adjust_contrast(20.0); + let _img2 = img.adjust_contrast(20.0); } diff --git a/server/tests/parity_test.rs b/server/tests/parity_test.rs index 950fc85..1797b91 100644 --- a/server/tests/parity_test.rs +++ b/server/tests/parity_test.rs @@ -101,9 +101,10 @@ fn test_dashboard_route_parity() { let mut registered_routes = HashSet::new(); for part in setup_content.split(".route(") { let trimmed = part.trim_start(); - if trimmed.starts_with('"') { - if let Some(end_quote) = trimmed[1..].find('"') { - let route = &trimmed[1..=end_quote]; + #[allow(clippy::collapsible_if)] + if let Some(stripped) = trimmed.strip_prefix('"') { + if let Some(end_quote) = stripped.find('"') { + let route = &stripped[..end_quote]; registered_routes.insert(route.to_string()); } } @@ -119,8 +120,10 @@ fn test_dashboard_route_parity() { let rest = &dashboard_content[start..]; let quote_char = dashboard_content[..start].chars().last(); let mut endpoint = String::new(); + #[allow(clippy::collapsible_if)] if let Some(q) = quote_char { - if q == '`' || q == '"' || q == '\'' { + let is_quote = q == '`' || q == '"' || q == '\''; + if is_quote { if let Some(close_idx) = rest.find(q) { let full_call = &rest[..close_idx]; let clean = if let Some(q_idx) = full_call.find('?') {