fix: apply automatic clippy fixes across workspace
This commit is contained in:
1 parent
73ab5037d8
commit
5da422d23a
12 files changed
+99
-115
No files matched your search
+1
-1
@@ -16,5 +16,5 @@ fn main() {
|
||||
.unwrap_or_else(|| "unknown".to_string());
|
||||
|
||||
let version = format!("{} ({})", git_date.trim(), git_hash.trim());
|
||||
println!("cargo:rustc-env=APP_VERSION={}", version);
|
||||
println!("cargo:rustc-env=APP_VERSION={version}");
|
||||
}
|
||||
@@ -17,7 +17,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.danger_accept_invalid_certs(true)
|
||||
.build()?;
|
||||
|
||||
let sse_url = format!("{}/sse", target);
|
||||
let sse_url = format!("{target}/sse");
|
||||
|
||||
tracing::info!("Connecting to SSE: {}", sse_url);
|
||||
|
||||
@@ -59,9 +59,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tracing::info!("Received POST endpoint: {}", data_content);
|
||||
post_endpoint = Some(data_content);
|
||||
break;
|
||||
} else {
|
||||
tracing::info!("Received early SSE data: {}", text);
|
||||
}
|
||||
tracing::info!("Received early SSE data: {}", text);
|
||||
}
|
||||
if post_endpoint.is_some() {
|
||||
break;
|
||||
@@ -69,7 +68,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
let post_endpoint = post_endpoint.ok_or("Did not receive endpoint from SSE stream")?;
|
||||
let post_url = format!("{}{}", target, post_endpoint);
|
||||
let post_url = format!("{target}{post_endpoint}");
|
||||
|
||||
let payload = r#"{"jsonrpc":"2.0","id":999,"method":"server/discover","params":{}}"#;
|
||||
|
||||
@@ -98,7 +97,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
_ = timeout.tick() => {
|
||||
tracing::warn!("Timed out waiting for SSE response.");
|
||||
}
|
||||
_ = async {
|
||||
() = async {
|
||||
while let Some(chunk) = stream.next().await {
|
||||
if let Ok(bytes) = chunk {
|
||||
tracing::info!("Received SSE Chunk: {}", String::from_utf8_lossy(&bytes));
|
||||
|
||||
+7
-10
@@ -14,31 +14,28 @@ pub fn extract_log_prefix(json_str: &str, is_response: bool) -> String {
|
||||
let id = ID_REGEX
|
||||
.captures(json_str)
|
||||
.and_then(|c| c.get(1))
|
||||
.map(|m| m.as_str())
|
||||
.unwrap_or("null");
|
||||
.map_or("null", |m| m.as_str());
|
||||
|
||||
if is_response {
|
||||
let is_error = ERROR_REGEX.is_match(json_str) || IS_ERROR_REGEX.is_match(json_str);
|
||||
return format!("Response id={} [Error: {}]", id, is_error);
|
||||
return format!("Response id={id} [Error: {is_error}]");
|
||||
}
|
||||
|
||||
let method = METHOD_REGEX
|
||||
.captures(json_str)
|
||||
.and_then(|c| c.get(1))
|
||||
.map(|m| m.as_str())
|
||||
.unwrap_or("");
|
||||
.map_or("", |m| m.as_str());
|
||||
|
||||
if method == "tools/call" {
|
||||
let tool = TOOL_REGEX
|
||||
.captures(json_str)
|
||||
.and_then(|c| c.get(1))
|
||||
.map(|m| m.as_str())
|
||||
.unwrap_or("unknown");
|
||||
format!("ToolCall[{}] id={}", tool, id)
|
||||
.map_or("unknown", |m| m.as_str());
|
||||
format!("ToolCall[{tool}] id={id}")
|
||||
} else if !method.is_empty() {
|
||||
format!("Request[{}] id={}", method, id)
|
||||
format!("Request[{method}] id={id}")
|
||||
} else if id != "null" {
|
||||
format!("Response id={}", id)
|
||||
format!("Response id={id}")
|
||||
} else {
|
||||
"Message".to_string()
|
||||
}
|
||||
|
||||
+6
-6
@@ -17,7 +17,7 @@ fn init_logging(app_name: &str) -> Option<tracing_appender::non_blocking::Worker
|
||||
base_dir.push(".gemini/mcp_memory/logs");
|
||||
std::fs::create_dir_all(&base_dir).unwrap_or_default();
|
||||
|
||||
let file_appender = tracing_appender::rolling::daily(base_dir, format!("{}.log", app_name));
|
||||
let file_appender = tracing_appender::rolling::daily(base_dir, format!("{app_name}.log"));
|
||||
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
|
||||
|
||||
let _ = tracing_subscriber::fmt()
|
||||
@@ -45,16 +45,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let _ = shutdown_tx.send(()).await;
|
||||
});
|
||||
|
||||
let target_url = if cli.target != "http://localhost:3000" {
|
||||
cli.target
|
||||
} else {
|
||||
let target_url = if cli.target == "http://localhost:3000" {
|
||||
let port = std::env::var("MCP_PORT").unwrap_or_else(|_| "3000".to_string());
|
||||
format!("http://127.0.0.1:{}", port)
|
||||
format!("http://127.0.0.1:{port}")
|
||||
} else {
|
||||
cli.target
|
||||
};
|
||||
let ws_url = target_url
|
||||
.replace("http://", "ws://")
|
||||
.replace("https://", "wss://");
|
||||
let ws_url = format!("{}/ws?client=proxy", ws_url);
|
||||
let ws_url = format!("{ws_url}/ws?client=proxy");
|
||||
|
||||
loop {
|
||||
if shutdown_rx.try_recv().is_ok() {
|
||||
|
||||
+11
-11
@@ -14,7 +14,7 @@ impl Drop for ChildGuard {
|
||||
|
||||
fn send_message(stdin: &mut std::process::ChildStdin, msg: Value) {
|
||||
let s = serde_json::to_string(&msg).unwrap();
|
||||
let payload = format!("{}\n", s);
|
||||
let payload = format!("{s}\n");
|
||||
stdin.write_all(payload.as_bytes()).unwrap();
|
||||
stdin.flush().unwrap();
|
||||
}
|
||||
@@ -56,9 +56,9 @@ async fn test_full_system_e2e_performance() {
|
||||
let nvim_exe = debug_dir.join(format!("{}{}", nvim_name, std::env::consts::EXE_SUFFIX));
|
||||
let stub_exe = debug_dir.join(format!("mcp-memory-stub{}", std::env::consts::EXE_SUFFIX));
|
||||
|
||||
assert!(server_exe.exists(), "Server not found at {:?}", server_exe);
|
||||
assert!(nvim_exe.exists(), "Nvim not found at {:?}", nvim_exe);
|
||||
assert!(stub_exe.exists(), "Stub not found at {:?}", stub_exe);
|
||||
assert!(server_exe.exists(), "Server not found at {server_exe:?}");
|
||||
assert!(nvim_exe.exists(), "Nvim not found at {nvim_exe:?}");
|
||||
assert!(stub_exe.exists(), "Stub not found at {stub_exe:?}");
|
||||
|
||||
// 1. Start Server
|
||||
let _server = ChildGuard(
|
||||
@@ -83,7 +83,7 @@ async fn test_full_system_e2e_performance() {
|
||||
let mut started = false;
|
||||
for _ in 0..30 {
|
||||
if let Ok(resp) = client
|
||||
.get(format!("http://127.0.0.1:{}/health", test_port))
|
||||
.get(format!("http://127.0.0.1:{test_port}/health"))
|
||||
.send()
|
||||
.await
|
||||
&& resp.status().is_success()
|
||||
@@ -99,7 +99,7 @@ async fn test_full_system_e2e_performance() {
|
||||
let mut stub = ChildGuard(
|
||||
Command::new(&stub_exe)
|
||||
.arg("--target")
|
||||
.arg(format!("http://127.0.0.1:{}", test_port))
|
||||
.arg(format!("http://127.0.0.1:{test_port}"))
|
||||
.env("MCP_MEMORY_STORE_DIR", temp_dir.to_str().unwrap())
|
||||
.env("MCP_AUTH_TOKEN", test_auth_token)
|
||||
.env("RUST_LOG", "debug")
|
||||
@@ -144,7 +144,7 @@ async fn test_full_system_e2e_performance() {
|
||||
send_message(&mut stub_stdin, tools_req);
|
||||
} else {
|
||||
let s = serde_json::to_string(&tools_req).unwrap();
|
||||
stub_stdin.write_all(format!("{}\n", s).as_bytes()).unwrap();
|
||||
stub_stdin.write_all(format!("{s}\n").as_bytes()).unwrap();
|
||||
stub_stdin.flush().unwrap();
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ async fn test_full_system_e2e_performance() {
|
||||
assert_eq!(resp["id"], i);
|
||||
}
|
||||
let stub_duration = start_time.elapsed();
|
||||
println!("Stub 100 requests: {:?}", stub_duration);
|
||||
println!("Stub 100 requests: {stub_duration:?}");
|
||||
|
||||
// Send 100 concurrent-like sequential rapid requests to Win-Nvim
|
||||
println!("Starting 100 requests to nvim...");
|
||||
@@ -173,7 +173,7 @@ async fn test_full_system_e2e_performance() {
|
||||
send_message(&mut nvim_stdin, tools_req);
|
||||
} else {
|
||||
let s = serde_json::to_string(&tools_req).unwrap();
|
||||
nvim_stdin.write_all(format!("{}\n", s).as_bytes()).unwrap();
|
||||
nvim_stdin.write_all(format!("{s}\n").as_bytes()).unwrap();
|
||||
nvim_stdin.flush().unwrap();
|
||||
}
|
||||
|
||||
@@ -187,8 +187,8 @@ async fn test_full_system_e2e_performance() {
|
||||
}
|
||||
let nvim_duration = start_time_nvim.elapsed();
|
||||
|
||||
println!("Stub 100 requests: {:?}", stub_duration);
|
||||
println!("Win-Nvim 100 requests: {:?}", nvim_duration);
|
||||
println!("Stub 100 requests: {stub_duration:?}");
|
||||
println!("Win-Nvim 100 requests: {nvim_duration:?}");
|
||||
|
||||
let _ = std::fs::remove_dir_all(temp_dir);
|
||||
}
|
||||
@@ -31,8 +31,7 @@ async fn test_stub_connection_refused() {
|
||||
|
||||
assert!(
|
||||
res.is_ok(),
|
||||
"Stub hung on connection refused! Took {:?}",
|
||||
elapsed
|
||||
"Stub hung on connection refused! Took {elapsed:?}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ async fn test_stub_handles_eof_cleanly() {
|
||||
let res = tokio::time::timeout(Duration::from_secs(5), child.wait()).await;
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
assert!(res.is_ok(), "Stub hung after EOF! Took {:?}", elapsed);
|
||||
assert!(res.is_ok(), "Stub hung after EOF! Took {elapsed:?}");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -102,7 +101,6 @@ async fn test_stub_sse_fallback_failure() {
|
||||
|
||||
assert!(
|
||||
res.is_ok(),
|
||||
"Stub hung on fallback failure! Took {:?}",
|
||||
elapsed
|
||||
"Stub hung on fallback failure! Took {elapsed:?}"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user