From 02fc16e10fd43d2498ea82d765e77933750265e2 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Tue, 5 May 2026 02:15:16 -0500 Subject: [PATCH] style: clippy sweep across community PRs (-D warnings) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 13 clippy errors had accumulated from squash-merged community PRs: collapsible-if (10), needless-late-init (1), derivable-impls (1), sort-unstable hint (1). All auto-fixable mechanical lints — no behaviour change. Required to satisfy CI's `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` gate. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/execpolicy/src/bash_arity.rs | 2 +- crates/execpolicy/src/lib.rs | 14 +--------- crates/tui/src/core/engine.rs | 12 ++++---- crates/tui/src/skills/install.rs | 31 ++++++++++----------- crates/tui/src/tools/large_output_router.rs | 8 +++--- crates/tui/src/tools/subagent/mod.rs | 25 ++++++++--------- crates/tui/src/tui/app.rs | 5 +++- 7 files changed, 42 insertions(+), 55 deletions(-) diff --git a/crates/execpolicy/src/bash_arity.rs b/crates/execpolicy/src/bash_arity.rs index 0902dca1..4d5b452b 100644 --- a/crates/execpolicy/src/bash_arity.rs +++ b/crates/execpolicy/src/bash_arity.rs @@ -287,7 +287,7 @@ impl BashArityDict { pub fn new() -> Self { let mut entries: Vec<(&'static str, u8)> = BASH_ARITY_TABLE.to_vec(); // Longest prefix first so greedy matching works correctly. - entries.sort_by(|a, b| b.0.len().cmp(&a.0.len())); + entries.sort_by_key(|entry| std::cmp::Reverse(entry.0.len())); Self { entries } } diff --git a/crates/execpolicy/src/lib.rs b/crates/execpolicy/src/lib.rs index 9d0b94f3..67c2d7a3 100644 --- a/crates/execpolicy/src/lib.rs +++ b/crates/execpolicy/src/lib.rs @@ -126,7 +126,7 @@ pub struct ExecPolicyContext<'a> { pub sandbox_mode: Option<&'a str>, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct ExecPolicyEngine { /// Layered rulesets (builtin → agent → user). When non-empty, takes precedence /// over the legacy flat lists below. @@ -139,18 +139,6 @@ pub struct ExecPolicyEngine { arity_dict: BashArityDict, } -impl Default for ExecPolicyEngine { - fn default() -> Self { - Self { - rulesets: vec![], - trusted_prefixes: Vec::new(), - denied_prefixes: Vec::new(), - approved_for_session: HashSet::new(), - arity_dict: BashArityDict::new(), - } - } -} - impl ExecPolicyEngine { /// Legacy constructor: wraps the two vecs into a User-layer ruleset. pub fn new(trusted_prefixes: Vec, denied_prefixes: Vec) -> Self { diff --git a/crates/tui/src/core/engine.rs b/crates/tui/src/core/engine.rs index 071a1f4b..32462b4b 100644 --- a/crates/tui/src/core/engine.rs +++ b/crates/tui/src/core/engine.rs @@ -1336,12 +1336,12 @@ impl Engine { // [workshop] config table is present; sub-agents don't inherit the // router (their ToolContext is built separately) to prevent recursive // routing of the synthesis call itself. - if let Some(workshop_cfg) = self.config.workshop.as_ref() { - if let Some(vars_arc) = self.workshop_vars.as_ref() { - let router = - crate::tools::large_output_router::LargeOutputRouter::new(workshop_cfg.clone()); - ctx = ctx.with_large_output_router(router, vars_arc.clone()); - } + if let Some(workshop_cfg) = self.config.workshop.as_ref() + && let Some(vars_arc) = self.workshop_vars.as_ref() + { + let router = + crate::tools::large_output_router::LargeOutputRouter::new(workshop_cfg.clone()); + ctx = ctx.with_large_output_router(router, vars_arc.clone()); } // Wire the external sandbox backend (#516). exec_shell checks this diff --git a/crates/tui/src/skills/install.rs b/crates/tui/src/skills/install.rs index 225cd471..95ac9757 100644 --- a/crates/tui/src/skills/install.rs +++ b/crates/tui/src/skills/install.rs @@ -658,10 +658,10 @@ async fn sync_one_skill( // Build the request — add If-None-Match if we have a cached ETag. let client = reqwest::Client::new(); let mut req = client.get(url); - if let Some(ref meta) = existing_meta { - if let Some(ref etag) = meta.etag { - req = req.header("If-None-Match", etag); - } + if let Some(ref meta) = existing_meta + && let Some(ref etag) = meta.etag + { + req = req.header("If-None-Match", etag); } let resp = match req.send().await { @@ -728,12 +728,13 @@ async fn sync_one_skill( // Short-circuit: if the hash matches the cached one, we're fresh even // without a 304 (some CDNs strip ETags on redirects). - if let Some(ref meta) = existing_meta { - if meta.sha256 == sha256 && meta.url == *url { - return SkillSyncOutcome::Fresh { - name: name.to_string(), - }; - } + if let Some(ref meta) = existing_meta + && meta.sha256 == sha256 + && meta.url == *url + { + return SkillSyncOutcome::Fresh { + name: name.to_string(), + }; } // Determine whether this is a tarball or a plain SKILL.md. @@ -742,9 +743,7 @@ async fn sync_one_skill( let is_tarball = url.ends_with(".tar.gz") || url.ends_with(".tgz") || bytes.starts_with(&[0x1f, 0x8b]); - let final_path: PathBuf; - - if is_tarball { + let final_path: PathBuf = if is_tarball { // Extract into a temp staging dir, then rename atomically. let staged = match stage_tarball(&bytes, cache_dir, max_size) { Ok(s) => s, @@ -767,7 +766,7 @@ async fn sync_one_skill( reason: format!("failed to move staged skill into cache: {err:#}"), }; } - final_path = dest; + dest } else { // Plain SKILL.md (or other companion text file). Write directly. if let Err(err) = fs::create_dir_all(&skill_cache_dir) { @@ -783,8 +782,8 @@ async fn sync_one_skill( reason: format!("failed to write SKILL.md to cache: {err:#}"), }; } - final_path = skill_cache_dir.clone(); - } + skill_cache_dir.clone() + }; // Write the updated freshness metadata. let meta = CacheMeta { diff --git a/crates/tui/src/tools/large_output_router.rs b/crates/tui/src/tools/large_output_router.rs index 6821693c..fc0048ed 100644 --- a/crates/tui/src/tools/large_output_router.rs +++ b/crates/tui/src/tools/large_output_router.rs @@ -51,10 +51,10 @@ impl WorkshopConfig { /// Resolve the effective threshold for the given tool name. #[must_use] pub fn threshold_for(&self, tool_name: &str) -> usize { - if let Some(per_tool) = self.per_tool_thresholds.as_ref() { - if let Some(&limit) = per_tool.get(tool_name) { - return limit; - } + if let Some(per_tool) = self.per_tool_thresholds.as_ref() + && let Some(&limit) = per_tool.get(tool_name) + { + return limit; } self.large_output_threshold_tokens .unwrap_or(DEFAULT_LARGE_OUTPUT_THRESHOLD_TOKENS) diff --git a/crates/tui/src/tools/subagent/mod.rs b/crates/tui/src/tools/subagent/mod.rs index 04363b54..89f2dd53 100644 --- a/crates/tui/src/tools/subagent/mod.rs +++ b/crates/tui/src/tools/subagent/mod.rs @@ -49,10 +49,10 @@ static RESIDENT_LEASES: std::sync::OnceLock< /// Release all resident file leases held by `agent_id`. Called when an /// agent transitions to a terminal state (completed, failed, cancelled). fn release_resident_leases_for(agent_id: &str) { - if let Some(lock) = RESIDENT_LEASES.get() { - if let Ok(mut guard) = lock.lock() { - guard.retain(|_, owner| owner != agent_id); - } + if let Some(lock) = RESIDENT_LEASES.get() + && let Ok(mut guard) = lock.lock() + { + guard.retain(|_, owner| owner != agent_id); } } @@ -1688,16 +1688,13 @@ impl ToolSpec for AgentSpawnTool { // (which matches by agent id at terminal-state transitions) can never find // the entry — leases would stay stamped as "pending" forever, defeating the // release machinery added in #660. - if let Some(ref file_path) = spawn_request.resident_file { - if let Some(lock) = RESIDENT_LEASES.get() { - if let Ok(mut guard) = lock.lock() { - if let Some(owner) = guard.get_mut(file_path) { - if owner == "pending" { - *owner = result.agent_id.clone(); - } - } - } - } + if let Some(ref file_path) = spawn_request.resident_file + && let Some(lock) = RESIDENT_LEASES.get() + && let Ok(mut guard) = lock.lock() + && let Some(owner) = guard.get_mut(file_path) + && owner == "pending" + { + *owner = result.agent_id.clone(); } let mut tool_result = if self.name == "spawn_agent" { diff --git a/crates/tui/src/tui/app.rs b/crates/tui/src/tui/app.rs index 08af4795..2d624309 100644 --- a/crates/tui/src/tui/app.rs +++ b/crates/tui/src/tui/app.rs @@ -1067,7 +1067,10 @@ impl App { let ui_locale = resolve_locale(&settings.locale); let composer_density = ComposerDensity::from_setting(&settings.composer_density); let composer_border = settings.composer_border; - let composer_vim_enabled = settings.composer_vim_mode.trim().to_ascii_lowercase() == "vim"; + let composer_vim_enabled = settings + .composer_vim_mode + .trim() + .eq_ignore_ascii_case("vim"); let transcript_spacing = TranscriptSpacing::from_setting(&settings.transcript_spacing); let sidebar_width_percent = settings.sidebar_width_percent; let sidebar_focus = SidebarFocus::from_setting(&settings.sidebar_focus);