From 608b07ceadac668d11674e1e3267c0797445daa4 Mon Sep 17 00:00:00 2001 From: Devid HW Date: Wed, 26 Aug 2026 05:02:44 +0700 Subject: [PATCH] fix(ci): satisfy rustfmt and clippy after bin+lib split The Rust workflow lint job failed on master: - cargo fmt --check: imports in src/main.rs were misordered (mcp_server/models/pipeline lines out of alphabetical order, McpError/McpRequest/McpResponse tuple unsorted) from b843146. - cargo clippy -D warnings: clippy::new_without_default now fires on DealAnalyzer, ReportExtractor, OptimizationParser, StageExecutor and McpServer because the lib target (src/lib.rs) makes their pub constructors part of the public API. Fix: reorder main.rs imports per rustfmt; add Default impls delegating to new() for the five types. --- src/analytics/analyze.rs | 6 ++++++ src/analytics/extract.rs | 6 ++++++ src/main.rs | 4 ++-- src/mcp_server.rs | 6 ++++++ src/optimization/parser.rs | 6 ++++++ src/pipeline/stages.rs | 7 +++++++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/analytics/analyze.rs b/src/analytics/analyze.rs index 184d31f..dc1fbaa 100644 --- a/src/analytics/analyze.rs +++ b/src/analytics/analyze.rs @@ -7,6 +7,12 @@ use crate::models::metrics::Metrics; pub struct DealAnalyzer; +impl Default for DealAnalyzer { + fn default() -> Self { + Self::new() + } +} + impl DealAnalyzer { pub fn new() -> Self { Self diff --git a/src/analytics/extract.rs b/src/analytics/extract.rs index cf95ed5..945646f 100644 --- a/src/analytics/extract.rs +++ b/src/analytics/extract.rs @@ -8,6 +8,12 @@ use crate::models::{Deal, Metrics}; pub struct ReportExtractor; +impl Default for ReportExtractor { + fn default() -> Self { + Self::new() + } +} + impl ReportExtractor { pub fn new() -> Self { Self diff --git a/src/main.rs b/src/main.rs index 0b1f38a..3efea36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,10 +7,10 @@ use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; use tokio::net::TcpListener; use tracing::{error, info}; +use mt5_quant::mcp_server::{McpServer, Notification}; use mt5_quant::models::Config; use mt5_quant::pipeline::backtest::{BacktestParams, BacktestPipeline}; -use mt5_quant::mcp_server::{McpServer, Notification}; -use mt5_quant::{McpRequest, McpResponse, McpError}; +use mt5_quant::{McpError, McpRequest, McpResponse}; #[derive(Parser)] #[command(name = "mt5-quant")] diff --git a/src/mcp_server.rs b/src/mcp_server.rs index c14971c..6e97b79 100644 --- a/src/mcp_server.rs +++ b/src/mcp_server.rs @@ -31,6 +31,12 @@ pub struct McpServer { notification_tx: Arc>>>, } +impl Default for McpServer { + fn default() -> Self { + Self::new() + } +} + impl McpServer { pub fn new() -> Self { let config = ModelsConfig::load().unwrap_or_default(); diff --git a/src/optimization/parser.rs b/src/optimization/parser.rs index 7016f86..d84652b 100644 --- a/src/optimization/parser.rs +++ b/src/optimization/parser.rs @@ -17,6 +17,12 @@ pub struct OptimizationPass { pub struct OptimizationParser; +impl Default for OptimizationParser { + fn default() -> Self { + Self::new() + } +} + impl OptimizationParser { pub fn new() -> Self { Self diff --git a/src/pipeline/stages.rs b/src/pipeline/stages.rs index 4eb0faa..34bdf97 100644 --- a/src/pipeline/stages.rs +++ b/src/pipeline/stages.rs @@ -40,6 +40,13 @@ impl Stage { #[allow(dead_code)] pub struct StageExecutor; +#[allow(dead_code)] +impl Default for StageExecutor { + fn default() -> Self { + Self::new() + } +} + #[allow(dead_code)] impl StageExecutor { pub fn new() -> Self {