Skip to content

Commit 0d06aa9

Browse files
committed
chore(lint): resolve clippy warnings across default and feature builds
Clean up all clippy lints across the default feature set and the memory/advisor/multimodal/pdf builds. Includes lints that only surface on clippy 1.96.0. Existing #[allow(clippy::too_many_arguments)] convention preserved for the three large builder/spawn functions to stay consistent with the ~17 pre-existing allows in the codebase. Fixes (clippy 1.96.0): - ui/renderer: prefix unused `rows` bindings with `_` (x3) - agent/runner: replace useless `format!` with `.to_string()` - config/mod: collapse nested `if let` into `if … && let …` (x2) - config/load: build rich default via struct literal + cfg-gated fields and `..Default::default()` instead of field reassignment after default - permission/checker: merge identical if/else branches into one condition - ui/status: replace manual `match` with `Option::map` - ui/mod: drop useless `.into()`, collapse nested `if let` (incl. advisor-gated) - ui/slash/add: collapse nested `if let` (multimodal-gated) - main: build capability list as a cfg-gated array literal instead of `Vec::new()` followed by pushes - extras/memory: elide redundant explicit lifetime in `truncate_to_bytes` - session/storage: `sort_by` -> `sort_by_key(Reverse(..))` - ui/pickers/models: `sort_by` -> `sort_by_key(Reverse(..))` - ui/status: manual checked division -> `checked_div(..).unwrap_or(0)`
1 parent 4213397 commit 0d06aa9

14 files changed

Lines changed: 94 additions & 99 deletions

File tree

src/agent/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ fn format_tool_args_summary(args_json: &serde_json::Value) -> String {
463463
} else {
464464
s
465465
};
466-
return format!("{}", truncated);
466+
return truncated.to_string();
467467
}
468468
}
469469
String::new()

src/config/load.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,29 +129,28 @@ pub fn save_quick_model(
129129
}
130130

131131
fn rich_default_config() -> Config {
132-
let mut cfg = Config::default();
133-
cfg.quick_models = Some(default_quick_models());
134-
cfg.provider = Some(CompactString::new("openrouter"));
135-
cfg.model = Some(CompactString::new("deepseek/deepseek-v4-pro"));
136-
cfg.max_tokens = Some(16384);
137-
cfg.compact_enabled = Some(true);
138-
cfg.max_text_file_size = Some(1_048_576);
139-
cfg.edit_system = Some(EditSystem::Similarity);
140-
cfg.default_permission_mode = Some("standard".to_string());
141-
cfg.default_prompt = Some(CompactString::new("code"));
142-
cfg.show_tool_details = None;
143-
#[cfg(feature = "subagents")]
144-
{
145-
cfg.subagent_max_read_lines = Some(2000);
146-
cfg.subagent_max_grep_results = Some(200);
147-
cfg.subagent_max_find_results = Some(200);
148-
}
149-
cfg.chain = Some(crate::config::types::ChainConfig::default());
150-
#[cfg(feature = "advisor")]
151-
{
152-
cfg.advisor = Some(crate::config::types::AdvisorConfig::default());
132+
Config {
133+
quick_models: Some(default_quick_models()),
134+
provider: Some(CompactString::new("openrouter")),
135+
model: Some(CompactString::new("deepseek/deepseek-v4-pro")),
136+
max_tokens: Some(16384),
137+
compact_enabled: Some(true),
138+
max_text_file_size: Some(1_048_576),
139+
edit_system: Some(EditSystem::Similarity),
140+
default_permission_mode: Some("standard".to_string()),
141+
default_prompt: Some(CompactString::new("code")),
142+
show_tool_details: None,
143+
chain: Some(crate::config::types::ChainConfig::default()),
144+
#[cfg(feature = "subagents")]
145+
subagent_max_read_lines: Some(2000),
146+
#[cfg(feature = "subagents")]
147+
subagent_max_grep_results: Some(200),
148+
#[cfg(feature = "subagents")]
149+
subagent_max_find_results: Some(200),
150+
#[cfg(feature = "advisor")]
151+
advisor: Some(crate::config::types::AdvisorConfig::default()),
152+
..Default::default()
153153
}
154-
cfg
155154
}
156155

157156
pub fn load() -> (Config, bool) {

src/config/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ impl Config {
213213
return rt;
214214
}
215215
for qmc in qm.values() {
216-
if qmc.model.as_str() == model_id {
217-
if let Some(rt) = qmc.reserve_tokens {
218-
return rt;
219-
}
216+
if qmc.model.as_str() == model_id
217+
&& let Some(rt) = qmc.reserve_tokens
218+
{
219+
return rt;
220220
}
221221
}
222222
8_192
@@ -238,10 +238,10 @@ impl Config {
238238
return Some(temp.clamp(0.0, 2.0));
239239
}
240240
for qmc in qm.values() {
241-
if qmc.model.as_str() == model_id {
242-
if let Some(temp) = qmc.temperature {
243-
return Some(temp.clamp(0.0, 2.0));
244-
}
241+
if qmc.model.as_str() == model_id
242+
&& let Some(temp) = qmc.temperature
243+
{
244+
return Some(temp.clamp(0.0, 2.0));
245245
}
246246
}
247247
self.temperature.map(|t| t.clamp(0.0, 2.0))

src/extras/memory/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Mem {
161161
}
162162
}
163163

164-
fn truncate_to_bytes<'a>(s: &'a str, max: usize) -> &'a str {
164+
fn truncate_to_bytes(s: &str, max: usize) -> &str {
165165
if s.len() <= max {
166166
return s;
167167
}

src/extras/subagents/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::provider::{AnyAgent, AnyModel, OpenAiAgent, OpenAiModel};
44
use rig::agent::{Agent, AgentBuilder};
55
use rig::completion::CompletionModel;
66

7+
#[allow(clippy::too_many_arguments)]
78
fn build_explore_agent_inner<M: CompletionModel + 'static>(
89
model: M,
910
max_turns: usize,

src/main.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,12 @@ async fn main() -> anyhow::Result<()> {
480480
content.clone()
481481
};
482482

483-
#[allow(unused_mut)]
484-
let mut caps: Vec<&str> = Vec::new();
485-
#[cfg(feature = "memory")]
486-
caps.push("- **Memory**: persistent memory across sessions (memory_read, memory_write, memory_search)");
487-
#[cfg(feature = "subagents")]
488-
caps.push("- **Subagents**: delegate specific multi-step investigations to parallel subagents via the `task` tool");
483+
let caps: &[&str] = &[
484+
#[cfg(feature = "memory")]
485+
"- **Memory**: persistent memory across sessions (memory_read, memory_write, memory_search)",
486+
#[cfg(feature = "subagents")]
487+
"- **Subagents**: delegate specific multi-step investigations to parallel subagents via the `task` tool",
488+
];
489489

490490
if !caps.is_empty() {
491491
prompt_text.push_str("\n\n## Available Capabilities\n\n");
@@ -508,12 +508,12 @@ async fn main() -> anyhow::Result<()> {
508508
content.clone()
509509
};
510510

511-
#[allow(unused_mut)]
512-
let mut caps: Vec<&str> = Vec::new();
513-
#[cfg(feature = "memory")]
514-
caps.push("- **Memory**: persistent memory across sessions (memory_read, memory_write, memory_search)");
515-
#[cfg(feature = "subagents")]
516-
caps.push("- **Subagents**: delegate specific multi-step investigations to parallel subagents via the `task` tool");
511+
let caps: &[&str] = &[
512+
#[cfg(feature = "memory")]
513+
"- **Memory**: persistent memory across sessions (memory_read, memory_write, memory_search)",
514+
#[cfg(feature = "subagents")]
515+
"- **Subagents**: delegate specific multi-step investigations to parallel subagents via the `task` tool",
516+
];
517517

518518
if !caps.is_empty() {
519519
prompt_text.push_str("\n\n## Available Capabilities\n\n");

src/permission/checker.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ impl PermissionChecker {
248248
}
249249
}),
250250
SecurityMode::PlanWrite => base.unwrap_or_else(|| {
251-
if self.is_read_tool(tool) {
252-
Action::Allow
253-
} else if matches!(tool, "write" | "edit") && is_plan_file(abs_path) {
251+
if self.is_read_tool(tool) || (matches!(tool, "write" | "edit") && is_plan_file(abs_path)) {
254252
Action::Allow
255253
} else {
256254
Action::Deny

src/provider.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ pub async fn build_agent(
882882
}
883883

884884
/// Builds the isolated, tool-less `/btw` agent for the active provider.
885+
#[allow(clippy::too_many_arguments)]
885886
pub fn build_btw_agent(
886887
model: AnyModel,
887888
cli: &Cli,

src/session/storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn find_recent_sessions(limit: usize) -> anyhow::Result<Vec<Session>> {
8888
.collect();
8989

9090
// Sort newest first
91-
entries.sort_by(|a, b| b.0.cmp(&a.0));
91+
entries.sort_by_key(|b| std::cmp::Reverse(b.0));
9292

9393
let mut sessions: Vec<Session> = Vec::new();
9494
for (_, path) in entries.iter().take(limit) {

src/ui/mod.rs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ pub(crate) fn classify_submission(is_running: bool, text: &str) -> SubmitAction
232232
}
233233

234234
#[cfg(feature = "git-worktree")]
235+
#[allow(clippy::too_many_arguments)]
235236
async fn spawn_merge_agent(
236237
branch: &str,
237238
target: &str,
@@ -1204,10 +1205,10 @@ pub async fn run_interactive(
12041205
"chain declined — won't ask again this session",
12051206
C_AGENT,
12061207
)?;
1207-
if let Some(ref name) = context.current_prompt_name {
1208-
if !context.chain_declined.contains(name) {
1209-
context.chain_declined.push(name.clone());
1210-
}
1208+
if let Some(ref name) = context.current_prompt_name
1209+
&& !context.chain_declined.contains(name)
1210+
{
1211+
context.chain_declined.push(name.clone());
12111212
}
12121213
refresh_display(&mut renderer, &mut input, session, is_running, loop_label.as_deref(), context.current_prompt_name.as_deref(), perm_mode().as_deref(), chain_label_msg.as_deref(), btw_total_cost, btw_total_in, btw_total_out)?;
12131214
continue;
@@ -1216,7 +1217,7 @@ pub async fn run_interactive(
12161217
renderer.chain_but_mode = true;
12171218
renderer.chain_prompt = None;
12181219
input.clear_buffer();
1219-
chain_label_msg = chain_pending.map(|p| p.chain_label().to_string().into());
1220+
chain_label_msg = chain_pending.map(|p| p.chain_label().to_string());
12201221
refresh_display(&mut renderer, &mut input, session, is_running, loop_label.as_deref(), context.current_prompt_name.as_deref(), perm_mode().as_deref(), chain_label_msg.as_deref(), btw_total_cost, btw_total_in, btw_total_out)?;
12211222
continue;
12221223
}
@@ -1980,30 +1981,30 @@ pub async fn run_interactive(
19801981
}
19811982

19821983
#[cfg(feature = "advisor")]
1983-
if let Some(ref mut rx) = handoff_rx {
1984-
if let Ok(handoff_req) = rx.try_recv() {
1985-
handle_human_handoff(
1986-
handoff_req,
1987-
&mut renderer,
1988-
&mut user_rx,
1989-
&mut agent_line_started,
1990-
&mut was_reasoning,
1991-
)
1992-
.await?;
1993-
refresh_display(
1994-
&mut renderer,
1995-
&mut input,
1996-
session,
1997-
is_running,
1998-
loop_label.as_deref(),
1999-
context.current_prompt_name.as_deref(),
2000-
perm_mode().as_deref(),
2001-
chain_label_msg.as_deref(),
2002-
btw_total_cost,
2003-
btw_total_in,
2004-
btw_total_out,
2005-
)?;
2006-
}
1984+
if let Some(ref mut rx) = handoff_rx
1985+
&& let Ok(handoff_req) = rx.try_recv()
1986+
{
1987+
handle_human_handoff(
1988+
handoff_req,
1989+
&mut renderer,
1990+
&mut user_rx,
1991+
&mut agent_line_started,
1992+
&mut was_reasoning,
1993+
)
1994+
.await?;
1995+
refresh_display(
1996+
&mut renderer,
1997+
&mut input,
1998+
session,
1999+
is_running,
2000+
loop_label.as_deref(),
2001+
context.current_prompt_name.as_deref(),
2002+
perm_mode().as_deref(),
2003+
chain_label_msg.as_deref(),
2004+
btw_total_cost,
2005+
btw_total_in,
2006+
btw_total_out,
2007+
)?;
20072008
}
20082009
}
20092010

0 commit comments

Comments
 (0)