diff --git a/src/commands/repo.rs b/src/commands/repo.rs index 6b7da6a..6dab778 100644 --- a/src/commands/repo.rs +++ b/src/commands/repo.rs @@ -77,7 +77,7 @@ pub fn run_discover(ctx: &mut crate::storage::AppContext) -> anyhow::Result<()> let sims = discover_similar_projects(&conn)?; let mut merged: HashMap<(String, String, String), Discovery> = HashMap::new(); - for d in deps.into_iter().chain(sims.into_iter()) { + for d in deps.into_iter().chain(sims) { let key = (d.from.clone(), d.to.clone(), d.relation_type.clone()); if let Some(existing) = merged.get(&key) { if d.confidence > existing.confidence { diff --git a/src/knowledge_engine/fallback.rs b/src/knowledge_engine/fallback.rs index e954f1e..842c9bf 100644 --- a/src/knowledge_engine/fallback.rs +++ b/src/knowledge_engine/fallback.rs @@ -28,7 +28,7 @@ pub fn generate_fallback_summary(path: &Path) -> (String, String) { } } let mut pairs: Vec<(String, usize)> = counts.into_iter().collect(); - pairs.sort_by(|a, b| b.1.cmp(&a.1)); + pairs.sort_by_key(|b| std::cmp::Reverse(b.1)); let top: Vec = pairs.into_iter().take(3).map(|(e, c)| format!("{}({})", e, c)).collect(); if top.is_empty() { diff --git a/src/mcp/tools/context.rs b/src/mcp/tools/context.rs index 68c55ef..a6507a1 100644 --- a/src/mcp/tools/context.rs +++ b/src/mcp/tools/context.rs @@ -517,7 +517,7 @@ fn collect_hot_files(repo_path: &std::path::Path, days: i64) -> Vec = file_counts.into_iter().collect(); - sorted.sort_by(|a, b| b.1.cmp(&a.1)); + sorted.sort_by_key(|b| std::cmp::Reverse(b.1)); sorted .into_iter() .take(10) diff --git a/src/tui/event.rs b/src/tui/event.rs index e44b89e..63189a3 100644 --- a/src/tui/event.rs +++ b/src/tui/event.rs @@ -202,15 +202,11 @@ pub(crate) async fn run_app( app.nlp_results.clear(); app.nlp_selected = 0; } - KeyCode::Down => { - if app.nlp_selected + 1 < app.nlp_results.len() { - app.nlp_selected += 1; - } + KeyCode::Down if app.nlp_selected + 1 < app.nlp_results.len() => { + app.nlp_selected += 1; } - KeyCode::Up => { - if app.nlp_selected > 0 { - app.nlp_selected -= 1; - } + KeyCode::Up if app.nlp_selected > 0 => { + app.nlp_selected -= 1; } _ => {} } @@ -240,15 +236,11 @@ pub(crate) async fn run_app( app.search_results.clear(); app.search_selected = 0; } - KeyCode::Down => { - if app.search_selected + 1 < app.search_results.len() { - app.search_selected += 1; - } + KeyCode::Down if app.search_selected + 1 < app.search_results.len() => { + app.search_selected += 1; } - KeyCode::Up => { - if app.search_selected > 0 { - app.search_selected -= 1; - } + KeyCode::Up if app.search_selected > 0 => { + app.search_selected -= 1; } KeyCode::Enter => { if let Some(result) = app.search_results.get(app.search_selected) {