style: clippy sweep across community PRs (-D warnings)

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) <noreply@anthropic.com>
This commit is contained in:
Hunter Bown
2026-05-05 02:15:16 -05:00
parent 6d0c708307
commit 02fc16e10f
7 changed files with 42 additions and 55 deletions
+1 -1
View File
@@ -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 }
}
+1 -13
View File
@@ -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<String>, denied_prefixes: Vec<String>) -> Self {
+6 -6
View File
@@ -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
+15 -16
View File
@@ -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 {
+4 -4
View File
@@ -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)
+11 -14
View File
@@ -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" {
+4 -1
View File
@@ -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);