style(server): fix all clippy warnings including derivable traits, redundant locals, collapsible blocks and needless borrows
This commit is contained in:
1 parent
4c4150a042
commit
58ad2e76a3
4 files changed
+11
-21
No files matched your search
@@ -1,4 +1,3 @@
|
|||||||
use crate::models::*;
|
|
||||||
use crate::router::McpTool;
|
use crate::router::McpTool;
|
||||||
use crate::state::MemoryState;
|
use crate::state::MemoryState;
|
||||||
use crate::tools::*;
|
use crate::tools::*;
|
||||||
@@ -8,19 +7,12 @@ use std::collections::HashSet;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
|
#[derive(Default)]
|
||||||
struct BorrowedGraph<'a> {
|
struct BorrowedGraph<'a> {
|
||||||
entities: std::collections::HashMap<&'a String, &'a crate::models::Entity>,
|
entities: std::collections::HashMap<&'a String, &'a crate::models::Entity>,
|
||||||
relations: Vec<&'a crate::models::Relation>,
|
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;
|
pub struct QueryGraphPathHandler;
|
||||||
|
|
||||||
|
|||||||
@@ -68,10 +68,9 @@ impl McpTool for QueryDecisionsHandler {
|
|||||||
let data = state.adrs.read_with(|adrs| {
|
let data = state.adrs.read_with(|adrs| {
|
||||||
let filtered: Vec<_> = adrs.iter().filter(|a| {
|
let filtered: Vec<_> = adrs.iter().filter(|a| {
|
||||||
if let Some(q) = &req.query {
|
if let Some(q) = &req.query {
|
||||||
let q = q;
|
contains_ignore_ascii_case(&a.title, q)
|
||||||
contains_ignore_ascii_case(&a.title, &q)
|
|| contains_ignore_ascii_case(&a.context, q)
|
||||||
|| contains_ignore_ascii_case(&a.context, &q)
|
|| contains_ignore_ascii_case(&a.decision, q)
|
||||||
|| contains_ignore_ascii_case(&a.decision, &q)
|
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,11 +216,10 @@ impl McpTool for UpdateTaskStatusHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (idx, t) in tasks.iter().enumerate() {
|
for (idx, t) in tasks.iter().enumerate() {
|
||||||
if let Some(pid) = &t.parent_id {
|
if let Some(pid) = &t.parent_id
|
||||||
if let Some(&p_idx) = id_to_idx.get(pid.as_str()) {
|
&& let Some(&p_idx) = id_to_idx.get(pid.as_str()) {
|
||||||
children_map.entry(p_idx).or_default().push(idx);
|
children_map.entry(p_idx).or_default().push(idx);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(&start_idx) = id_to_idx.get(target_id.as_str()) {
|
if let Some(&start_idx) = id_to_idx.get(target_id.as_str()) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl McpTool for PinFileHandler {
|
|||||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||||
let req: PinFileTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
let req: PinFileTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||||
state.pinned_files.modify(|pinned| {
|
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 {
|
pinned.push(crate::models::PinnedFile {
|
||||||
namespace: req.namespace,
|
namespace: req.namespace,
|
||||||
file_path: req.file_path,
|
file_path: req.file_path,
|
||||||
@@ -52,7 +52,7 @@ impl McpTool for UnpinFileHandler {
|
|||||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||||
let req: UnpinFileTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
let req: UnpinFileTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||||
state.pinned_files.modify(|pinned| {
|
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())
|
Ok("File unpinned".to_string())
|
||||||
}
|
}
|
||||||
@@ -79,11 +79,11 @@ impl McpTool for ListPinnedFilesHandler {
|
|||||||
let filtered: Vec<_> = pinned.iter().filter(|p| {
|
let filtered: Vec<_> = pinned.iter().filter(|p| {
|
||||||
let ns_match = match &req.namespace {
|
let ns_match = match &req.namespace {
|
||||||
Some(ns) => &p.namespace == ns,
|
Some(ns) => &p.namespace == ns,
|
||||||
None => true,
|
std::option::Option::None => true,
|
||||||
};
|
};
|
||||||
let branch_match = match &req.git_branch {
|
let branch_match = match &req.git_branch {
|
||||||
Some(branch) => p.git_branch.is_none() || p.git_branch.as_deref() == Some(branch.as_str()),
|
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
|
ns_match && branch_match
|
||||||
}).collect();
|
}).collect();
|
||||||
@@ -206,7 +206,7 @@ impl McpTool for SaveContextWorkspaceHandler {
|
|||||||
let req: SaveContextWorkspaceTool =
|
let req: SaveContextWorkspaceTool =
|
||||||
serde_json::from_value(args).map_err(|e| e.to_string())?;
|
serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||||
state.context_workspaces.modify(|ws| {
|
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 {
|
ws.push(crate::models::ContextWorkspace {
|
||||||
namespace: req.namespace,
|
namespace: req.namespace,
|
||||||
name: req.name,
|
name: req.name,
|
||||||
|
|||||||
Reference in new issue
Block a user