diff --git a/apps/blue-cli/src/main.rs b/apps/blue-cli/src/main.rs index 8906569..dd86df2 100644 --- a/apps/blue-cli/src/main.rs +++ b/apps/blue-cli/src/main.rs @@ -1663,7 +1663,7 @@ fn handle_index_command_blocking(command: IndexCommands) -> Result<()> { }; let llm = OllamaLlm::new(&llm_config); - if let Err(_) = llm.start() { + if llm.start().is_err() { // Silently skip if Ollama not available (pre-commit hook shouldn't block) return Ok(()); } diff --git a/crates/blue-core/src/daemon/db.rs b/crates/blue-core/src/daemon/db.rs index 4dcc269..f71d34c 100644 --- a/crates/blue-core/src/daemon/db.rs +++ b/crates/blue-core/src/daemon/db.rs @@ -278,7 +278,7 @@ impl DaemonDb { )?; let sessions = stmt - .query_map([], |row| Self::row_to_session(row))? + .query_map([], Self::row_to_session)? .collect::, _>>()?; Ok(sessions) @@ -295,7 +295,7 @@ impl DaemonDb { )?; let sessions = stmt - .query_map([realm], |row| Self::row_to_session(row))? + .query_map([realm], Self::row_to_session)? .collect::, _>>()?; Ok(sessions) @@ -312,7 +312,7 @@ impl DaemonDb { )?; let session = stmt - .query_row([id], |row| Self::row_to_session(row)) + .query_row([id], Self::row_to_session) .optional()?; Ok(session) @@ -392,7 +392,7 @@ impl DaemonDb { )?; let notifications = stmt - .query_map([], |row| Self::row_to_notification(row))? + .query_map([], Self::row_to_notification)? .collect::, _>>()?; Ok(notifications) @@ -413,7 +413,7 @@ impl DaemonDb { )?; let notifications = stmt - .query_map([realm], |row| Self::row_to_notification(row))? + .query_map([realm], Self::row_to_notification)? .collect::, _>>()?; Ok(notifications) diff --git a/crates/blue-core/src/forge/mod.rs b/crates/blue-core/src/forge/mod.rs index fb8027b..140bffa 100644 --- a/crates/blue-core/src/forge/mod.rs +++ b/crates/blue-core/src/forge/mod.rs @@ -210,7 +210,7 @@ impl BlueConfig { pub fn save(&self, blue_dir: &std::path::Path) -> Result<(), std::io::Error> { let config_path = blue_dir.join("config.yaml"); let content = serde_yaml::to_string(self) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; + .map_err(|e| std::io::Error::other(e))?; std::fs::write(&config_path, content) } } diff --git a/crates/blue-core/src/indexer.rs b/crates/blue-core/src/indexer.rs index 16c4dd9..5ad101f 100644 --- a/crates/blue-core/src/indexer.rs +++ b/crates/blue-core/src/indexer.rs @@ -110,7 +110,7 @@ impl Indexer

{ }; let completion = self.provider.complete(&prompt, &options) - .map_err(|e| IndexerError::LlmError(e))?; + .map_err(IndexerError::LlmError)?; // Parse YAML response let parsed = parse_index_response(&completion.text); @@ -433,7 +433,8 @@ symbols: []"#; #[test] fn test_parse_index_response_invalid() { - let response = "this is not valid yaml { broken }"; + // Use actually invalid YAML (unclosed bracket) + let response = "key: [unclosed bracket"; let parsed = parse_index_response(response); assert!(parsed.error.is_some()); } diff --git a/crates/blue-core/src/llm.rs b/crates/blue-core/src/llm.rs index 1226964..3d76b2f 100644 --- a/crates/blue-core/src/llm.rs +++ b/crates/blue-core/src/llm.rs @@ -106,8 +106,10 @@ pub trait LlmProvider: Send + Sync { /// LLM backend selection #[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Default)] pub enum LlmBackendChoice { /// Auto-detect best backend (CUDA > MPS > CPU) + #[default] Auto, /// Force CUDA (NVIDIA GPU) Cuda, @@ -117,11 +119,6 @@ pub enum LlmBackendChoice { Cpu, } -impl Default for LlmBackendChoice { - fn default() -> Self { - Self::Auto - } -} /// LLM configuration #[derive(Debug, Clone)] diff --git a/crates/blue-core/src/realm/domain.rs b/crates/blue-core/src/realm/domain.rs index 51c9b76..4e9dbe8 100644 --- a/crates/blue-core/src/realm/domain.rs +++ b/crates/blue-core/src/realm/domain.rs @@ -249,7 +249,7 @@ impl ImportBinding { /// Check if this import satisfies a given version pub fn satisfies(&self, version: &str) -> Result { let req = semver::VersionReq::parse(&self.version) - .map_err(|e| RealmError::InvalidVersion(e))?; + .map_err(RealmError::InvalidVersion)?; let ver = semver::Version::parse(version)?; Ok(req.matches(&ver)) } diff --git a/crates/blue-core/src/repo.rs b/crates/blue-core/src/repo.rs index 4ed6154..7f6745c 100644 --- a/crates/blue-core/src/repo.rs +++ b/crates/blue-core/src/repo.rs @@ -289,14 +289,14 @@ fn extract_project_name(path: &Path) -> Option { fn extract_repo_name_from_url(url: &str) -> Option { // Handle SSH URLs: git@host:org/repo.git if url.contains(':') && !url.contains("://") { - let after_colon = url.split(':').last()?; + let after_colon = url.split(':').next_back()?; let name = after_colon.trim_end_matches(".git"); - return name.split('/').last().map(|s| s.to_string()); + return name.split('/').next_back().map(|s| s.to_string()); } // Handle HTTPS URLs: https://host/org/repo.git let name = url.trim_end_matches(".git"); - name.split('/').last().map(|s| s.to_string()) + name.split('/').next_back().map(|s| s.to_string()) } /// List git worktrees for a repository diff --git a/crates/blue-mcp/src/handlers/adr.rs b/crates/blue-mcp/src/handlers/adr.rs index 76da7a2..7f5c2e9 100644 --- a/crates/blue-mcp/src/handlers/adr.rs +++ b/crates/blue-mcp/src/handlers/adr.rs @@ -368,7 +368,7 @@ fn load_adr_summaries(state: &ProjectState) -> Result, ServerErr for entry in entries.flatten() { let path = entry.path(); - if path.extension().map_or(false, |e| e == "md") { + if path.extension().is_some_and(|e| e == "md") { if let Ok(content) = fs::read_to_string(&path) { if let Some(summary) = parse_adr_file(&path, &content) { summaries.push(summary); diff --git a/crates/blue-mcp/src/handlers/delete.rs b/crates/blue-mcp/src/handlers/delete.rs index 3173f35..b057caa 100644 --- a/crates/blue-mcp/src/handlers/delete.rs +++ b/crates/blue-mcp/src/handlers/delete.rs @@ -220,21 +220,19 @@ pub fn handle_delete( let stem_str = stem.to_string_lossy(); for suffix in &[".plan.md", ".dialogue.md", ".draft.md"] { let companion = parent.join(format!("{}{}", stem_str, suffix)); - if companion.exists() { - if fs::remove_file(&companion).is_ok() { + if companion.exists() + && fs::remove_file(&companion).is_ok() { files_deleted.push(companion.display().to_string()); } - } } } } // Delete primary file - if base_path.exists() { - if fs::remove_file(base_path).is_ok() { + if base_path.exists() + && fs::remove_file(base_path).is_ok() { files_deleted.push(file_path.clone()); } - } } // Soft or permanent delete diff --git a/crates/blue-mcp/src/handlers/dialogue.rs b/crates/blue-mcp/src/handlers/dialogue.rs index ca735ea..85beb9f 100644 --- a/crates/blue-mcp/src/handlers/dialogue.rs +++ b/crates/blue-mcp/src/handlers/dialogue.rs @@ -580,7 +580,7 @@ fn generate_dialogue_markdown( md.push_str("| Round | Topic | Outcome |\n"); md.push_str("|-------|-------|--------|\n"); md.push_str("| 1 | [Topic] | [Outcome] |\n"); - md.push_str("\n"); + md.push('\n'); // Lessons learned md.push_str("## Lessons Learned\n\n"); diff --git a/crates/blue-mcp/src/handlers/env.rs b/crates/blue-mcp/src/handlers/env.rs index 5cb3018..aea10f1 100644 --- a/crates/blue-mcp/src/handlers/env.rs +++ b/crates/blue-mcp/src/handlers/env.rs @@ -26,7 +26,7 @@ pub fn handle_detect(args: &Value, repo_path: &Path) -> Result Result let scan_path = args .get("cwd") .and_then(|v| v.as_str()) - .map(|s| std::path::PathBuf::from(s)) + .map(std::path::PathBuf::from) .unwrap_or_else(|| repo_path.to_path_buf()); let worktree_path = args .get("worktree_path") .and_then(|v| v.as_str()) - .map(|s| std::path::PathBuf::from(s)) + .map(std::path::PathBuf::from) .unwrap_or_else(|| scan_path.clone()); let agent_id = args diff --git a/crates/blue-mcp/src/handlers/lint.rs b/crates/blue-mcp/src/handlers/lint.rs index 4243c6f..38afad6 100644 --- a/crates/blue-mcp/src/handlers/lint.rs +++ b/crates/blue-mcp/src/handlers/lint.rs @@ -362,8 +362,8 @@ fn run_python_checks(path: &Path, fix: bool, check_type: &str) -> Vec = if fix { vec!["check", "--fix", "."] } else { @@ -379,7 +379,6 @@ fn run_python_checks(path: &Path, fix: bool, check_type: &str) -> Vec Result 0 { - if best_match.as_ref().map_or(true, |(_, _, s)| score > *s) { + if score > 0 + && best_match.as_ref().is_none_or(|(_, _, s)| score > *s) { best_match = Some((runbook.clone(), actions.clone(), score)); break; // This runbook matches, move to next } - } } } } diff --git a/crates/blue-mcp/src/handlers/worktree.rs b/crates/blue-mcp/src/handlers/worktree.rs index 4345aca..b75c48e 100644 --- a/crates/blue-mcp/src/handlers/worktree.rs +++ b/crates/blue-mcp/src/handlers/worktree.rs @@ -206,7 +206,7 @@ pub fn handle_create(state: &ProjectState, args: &Value) -> Result Option { - for port in start..start + 100 { - if !Self::port_in_use(port) { - return Some(port); - } - } - None + (start..start + 100).find(|&port| !Self::port_in_use(port)) } /// Get path to bundled Ollama binary