From 34732e9d28df960a586e549fb8455978ec9ba16f Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 25 Jun 2026 02:44:34 +0200 Subject: [PATCH] fix(lint): resolve 4 clippy -D warnings gate failures Refs #2933 - weather_report: collapse nested if-let/if into let-chain (collapsible_if) - merge_coordinator: wrap const assertions in const{} blocks (assertions_on_constants) - terraphim_validation: remove trivial assert!(true) (assertions_on_constants) - terraphim_server: move build_router_for_tests before mod tests (items_after_test_module) `cargo clippy --workspace --all-targets -- -D warnings` now passes clean. Co-Authored-By: Ferrox --- .../terraphim_merge_coordinator/src/gitea.rs | 20 +++--- crates/terraphim_validation/src/lib.rs | 3 +- crates/terraphim_weather_report/src/main.rs | 9 +-- terraphim_server/src/lib.rs | 66 +++++++++---------- 4 files changed, 51 insertions(+), 47 deletions(-) diff --git a/crates/terraphim_merge_coordinator/src/gitea.rs b/crates/terraphim_merge_coordinator/src/gitea.rs index 8c0fbb196..ca0619373 100644 --- a/crates/terraphim_merge_coordinator/src/gitea.rs +++ b/crates/terraphim_merge_coordinator/src/gitea.rs @@ -212,18 +212,22 @@ mod tests { #[test] fn open_prs_limit_exceeds_gitea_default_of_50() { - assert!( - OPEN_PRS_LIMIT > 50, - "OPEN_PRS_LIMIT must exceed 50 so PRs beyond position 50 are not silently dropped" - ); + const { + assert!( + OPEN_PRS_LIMIT > 50, + "OPEN_PRS_LIMIT must exceed 50 so PRs beyond position 50 are not silently dropped" + ) + } } #[test] fn open_prs_limit_within_gitea_max_page_size() { - assert!( - OPEN_PRS_LIMIT <= 300, - "Gitea max page size is 300; limit must not exceed it" - ); + const { + assert!( + OPEN_PRS_LIMIT <= 300, + "Gitea max page size is 300; limit must not exceed it" + ) + } } #[test] diff --git a/crates/terraphim_validation/src/lib.rs b/crates/terraphim_validation/src/lib.rs index 071179fe8..0b896b183 100644 --- a/crates/terraphim_validation/src/lib.rs +++ b/crates/terraphim_validation/src/lib.rs @@ -61,7 +61,6 @@ mod tests { #[tokio::test] async fn test_validation_system_creation() { - let system = ValidationSystem::new().unwrap(); - assert!(true); // Basic creation test + let _system = ValidationSystem::new().unwrap(); } } diff --git a/crates/terraphim_weather_report/src/main.rs b/crates/terraphim_weather_report/src/main.rs index 4fc804dda..d3cebcd46 100644 --- a/crates/terraphim_weather_report/src/main.rs +++ b/crates/terraphim_weather_report/src/main.rs @@ -350,10 +350,11 @@ fn print_tier_markdown(tier: &terraphim_weather_report::TierSection) { "| {} | {} | `{}` | {} | {} | {} |", cond, m.provider, m.model, m.cli, latency, cost ); - if let Some(detail) = &m.detail { - if !detail.is_empty() && !detail.starts_with("probe skipped") { - println!("| | | | | | *{}* |", detail.replace('|', "\\|")); - } + if let Some(detail) = &m.detail + && !detail.is_empty() + && !detail.starts_with("probe skipped") + { + println!("| | | | | | *{}* |", detail.replace('|', "\\|")); } } println!(); diff --git a/terraphim_server/src/lib.rs b/terraphim_server/src/lib.rs index d4bade779..de7d37a90 100644 --- a/terraphim_server/src/lib.rs +++ b/terraphim_server/src/lib.rs @@ -629,6 +629,39 @@ async fn not_found() -> Response { (StatusCode::NOT_FOUND, "404").into_response() } +/// Constructs a minimal Axum router suitable for integration tests. +pub async fn build_router_for_tests() -> Router { + use terraphim_config::ConfigBuilder; + + // Create minimal test configuration + let mut config = ConfigBuilder::new() + .build_default_embedded() + .build() + .expect("Failed to build test config"); + + let config_state = ConfigState::new(&mut config) + .await + .expect("Failed to create ConfigState"); + + let (tx, _rx) = channel::(10); + + // Initialize summarization manager + let summarization_manager = Arc::new(SummarizationManager::new(QueueConfig::default())); + + // Initialize workflow management components for tests + let workflow_sessions = Arc::new(RwLock::new(HashMap::new())); + let (websocket_broadcaster, _) = broadcast::channel(100); + + // Create extended application state for tests + let app_state = AppState { + config_state, + workflow_sessions, + websocket_broadcaster, + }; + + build_router(app_state, tx, summarization_manager, false) +} + #[cfg(test)] mod tests { use super::*; @@ -860,36 +893,3 @@ mod tests { assert!(!desc.is_empty()); } } - -/// Constructs a minimal Axum router suitable for integration tests. -pub async fn build_router_for_tests() -> Router { - use terraphim_config::ConfigBuilder; - - // Create minimal test configuration - let mut config = ConfigBuilder::new() - .build_default_embedded() - .build() - .expect("Failed to build test config"); - - let config_state = ConfigState::new(&mut config) - .await - .expect("Failed to create ConfigState"); - - let (tx, _rx) = channel::(10); - - // Initialize summarization manager - let summarization_manager = Arc::new(SummarizationManager::new(QueueConfig::default())); - - // Initialize workflow management components for tests - let workflow_sessions = Arc::new(RwLock::new(HashMap::new())); - let (websocket_broadcaster, _) = broadcast::channel(100); - - // Create extended application state for tests - let app_state = AppState { - config_state, - workflow_sessions, - websocket_broadcaster, - }; - - build_router(app_state, tx, summarization_manager, false) -}