From 1f2a8d9e5ec206348471f8a814be0570fc54b611 Mon Sep 17 00:00:00 2001 From: Lyn Nagara Date: Thu, 18 Jun 2026 11:46:59 -0700 Subject: [PATCH] fix clippy warnings fixes clippy warnings around test ordering, nested ifs, useless type conversions --- ingest-router/src/testutils.rs | 6 ++--- shared/src/http.rs | 42 +++++++++++++++++----------------- synapse/src/config.rs | 12 +++++----- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ingest-router/src/testutils.rs b/ingest-router/src/testutils.rs index 0a452bd..305ecad 100644 --- a/ingest-router/src/testutils.rs +++ b/ingest-router/src/testutils.rs @@ -10,9 +10,9 @@ use std::sync::Arc; pub async fn get_mock_provider() -> (tempfile::TempDir, FilesystemRouteProvider) { let route_data = RouteData::from( HashMap::from([ - ("a".repeat(32).into(), "us1".into()), - ("b".repeat(32).into(), "us1".into()), - ("c".repeat(32).into(), "de".into()), + ("a".repeat(32), "us1".into()), + ("b".repeat(32), "us1".into()), + ("c".repeat(32), "de".into()), ]), Some("cursor1".into()), HashMap::from([("us1".into(), "us".into()), ("de".into(), "de".into())]), diff --git a/shared/src/http.rs b/shared/src/http.rs index ccc0a36..b3f3f5b 100644 --- a/shared/src/http.rs +++ b/shared/src/http.rs @@ -133,6 +133,27 @@ pub fn filter_hop_by_hop(headers: &mut HeaderMap, version: Version) -> &mut Head headers } +/// Creates an error response with the status message as body. +pub fn make_error_response(status_code: StatusCode) -> Response { + let message = status_code + .canonical_reason() + .unwrap_or("an error occurred"); + + let mut response = Response::new(Bytes::from(message)); + *response.status_mut() = status_code; + response +} + +/// Boxed version for services that need BoxBody (e.g., streaming proxies) +pub fn make_boxed_error_response(status_code: StatusCode) -> Response> +where + E: 'static, +{ + make_error_response(status_code) + .map(Full::new) + .map(|body| body.map_err(|e| match e {}).boxed()) +} + #[cfg(test)] mod tests { use super::*; @@ -163,24 +184,3 @@ mod tests { assert!(filtered.get("custom").is_none()); } } - -/// Creates an error response with the status message as body. -pub fn make_error_response(status_code: StatusCode) -> Response { - let message = status_code - .canonical_reason() - .unwrap_or("an error occurred"); - - let mut response = Response::new(Bytes::from(message)); - *response.status_mut() = status_code; - response -} - -/// Boxed version for services that need BoxBody (e.g., streaming proxies) -pub fn make_boxed_error_response(status_code: StatusCode) -> Response> -where - E: 'static, -{ - make_error_response(status_code) - .map(Full::new) - .map(|body| body.map_err(|e| match e {}).boxed()) -} diff --git a/synapse/src/config.rs b/synapse/src/config.rs index a085c10..51e5eff 100644 --- a/synapse/src/config.rs +++ b/synapse/src/config.rs @@ -161,12 +161,12 @@ mod tests { for entry in std::fs::read_dir(root_dir).unwrap() { let path = entry.unwrap().path(); - if path.is_file() { - if let Some(name) = path.file_name().and_then(|n| n.to_str()) { - if name.starts_with("example_config") && name.ends_with(".yaml") { - let _ = Config::from_file(&path).expect("load config"); - } - } + if path.is_file() + && let Some(name) = path.file_name().and_then(|n| n.to_str()) + && name.starts_with("example_config") + && name.ends_with(".yaml") + { + let _ = Config::from_file(&path).expect("load config"); } } }