From 58ad2e76a34178a3a90dcb9ade186164c0775947 Mon Sep 17 00:00:00 2001 From: Riz Ashraf Date: Mon, 21 Sep 2026 17:08:57 +0100 Subject: [PATCH] style(server): fix all clippy warnings including derivable traits, redundant locals, collapsible blocks and needless borrows --- server/src/handlers_v2/graph.rs | 10 +--------- server/src/handlers_v2/meta.rs | 7 +++---- server/src/handlers_v2/tasks.rs | 5 ++--- server/src/handlers_v2/workspaces.rs | 10 +++++----- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/server/src/handlers_v2/graph.rs b/server/src/handlers_v2/graph.rs index c0c120f..4d31487 100644 --- a/server/src/handlers_v2/graph.rs +++ b/server/src/handlers_v2/graph.rs @@ -1,4 +1,3 @@ -use crate::models::*; use crate::router::McpTool; use crate::state::MemoryState; use crate::tools::*; @@ -8,19 +7,12 @@ use std::collections::HashSet; use std::sync::Arc; #[derive(serde::Serialize)] +#[derive(Default)] struct BorrowedGraph<'a> { entities: std::collections::HashMap<&'a String, &'a crate::models::Entity>, relations: Vec<&'a crate::models::Relation>, } -impl<'a> Default for BorrowedGraph<'a> { - fn default() -> Self { - Self { - entities: std::collections::HashMap::new(), - relations: Vec::new(), - } - } -} pub struct QueryGraphPathHandler; diff --git a/server/src/handlers_v2/meta.rs b/server/src/handlers_v2/meta.rs index 9b3a933..069225f 100644 --- a/server/src/handlers_v2/meta.rs +++ b/server/src/handlers_v2/meta.rs @@ -68,10 +68,9 @@ impl McpTool for QueryDecisionsHandler { let data = state.adrs.read_with(|adrs| { let filtered: Vec<_> = adrs.iter().filter(|a| { if let Some(q) = &req.query { - let q = q; - contains_ignore_ascii_case(&a.title, &q) - || contains_ignore_ascii_case(&a.context, &q) - || contains_ignore_ascii_case(&a.decision, &q) + contains_ignore_ascii_case(&a.title, q) + || contains_ignore_ascii_case(&a.context, q) + || contains_ignore_ascii_case(&a.decision, q) } else { true } diff --git a/server/src/handlers_v2/tasks.rs b/server/src/handlers_v2/tasks.rs index 4dcd16f..2508fda 100644 --- a/server/src/handlers_v2/tasks.rs +++ b/server/src/handlers_v2/tasks.rs @@ -216,11 +216,10 @@ impl McpTool for UpdateTaskStatusHandler { } for (idx, t) in tasks.iter().enumerate() { - if let Some(pid) = &t.parent_id { - if let Some(&p_idx) = id_to_idx.get(pid.as_str()) { + if let Some(pid) = &t.parent_id + && let Some(&p_idx) = id_to_idx.get(pid.as_str()) { children_map.entry(p_idx).or_default().push(idx); } - } } if let Some(&start_idx) = id_to_idx.get(target_id.as_str()) { diff --git a/server/src/handlers_v2/workspaces.rs b/server/src/handlers_v2/workspaces.rs index daab8fb..1131820 100644 --- a/server/src/handlers_v2/workspaces.rs +++ b/server/src/handlers_v2/workspaces.rs @@ -22,7 +22,7 @@ impl McpTool for PinFileHandler { async fn execute(&self, args: Value, state: Arc) -> Result { let req: PinFileTool = serde_json::from_value(args).map_err(|e| e.to_string())?; state.pinned_files.modify(|pinned| { - pinned.retain(|p| !(p.namespace == req.namespace && p.file_path == req.file_path)); + pinned.retain(|p| p.namespace != req.namespace || p.file_path != req.file_path); pinned.push(crate::models::PinnedFile { namespace: req.namespace, file_path: req.file_path, @@ -52,7 +52,7 @@ impl McpTool for UnpinFileHandler { async fn execute(&self, args: Value, state: Arc) -> Result { let req: UnpinFileTool = serde_json::from_value(args).map_err(|e| e.to_string())?; state.pinned_files.modify(|pinned| { - pinned.retain(|p| !(p.namespace == req.namespace && p.file_path == req.file_path)) + pinned.retain(|p| p.namespace != req.namespace || p.file_path != req.file_path) }); Ok("File unpinned".to_string()) } @@ -79,11 +79,11 @@ impl McpTool for ListPinnedFilesHandler { let filtered: Vec<_> = pinned.iter().filter(|p| { let ns_match = match &req.namespace { Some(ns) => &p.namespace == ns, - None => true, + std::option::Option::None => true, }; let branch_match = match &req.git_branch { Some(branch) => p.git_branch.is_none() || p.git_branch.as_deref() == Some(branch.as_str()), - None => true, + std::option::Option::None => true, }; ns_match && branch_match }).collect(); @@ -206,7 +206,7 @@ impl McpTool for SaveContextWorkspaceHandler { let req: SaveContextWorkspaceTool = serde_json::from_value(args).map_err(|e| e.to_string())?; state.context_workspaces.modify(|ws| { - ws.retain(|w| !(w.namespace == req.namespace && w.name == req.name)); + ws.retain(|w| w.namespace != req.namespace || w.name != req.name); ws.push(crate::models::ContextWorkspace { namespace: req.namespace, name: req.name,