chore: collapse the ifs the 1.98 clippy flags

The pinned toolchain's clippy grew opinions the older lint let stand:
nested if/if-let pairs it wants as let-chains, and a modulo test it
wants as is_multiple_of. Machine-applied collapses, fmt-settled, no
behavior change — the gauntlet runs clean again.
This commit is contained in:
vhaudiquet committed 2026-10-27 01:12:46 -05:00
1 parent 50e0a3b949
commit e92739aa1b
12 files changed
+50 -52

No files matched your search

+1 -3
View File
@@ -132,8 +132,7 @@ pub fn save_account(
forge_known: forge.is_some(), forge_known: forge.is_some(),
watch_added: false, watch_added: false,
}; };
if watch { if watch && let Some(kind) = forge {
if let Some(kind) = forge {
let host = saved.account.url.as_deref().filter(|url| !url.is_empty()); let host = saved.account.url.as_deref().filter(|url| !url.is_empty());
saved.watch_added = watches saved.watch_added = watches
.add_account_watch(kind.name(), host, &saved.account.id) .add_account_watch(kind.name(), host, &saved.account.id)
@@ -141,7 +140,6 @@ pub fn save_account(
} }
// Asked to watch a service the daemon cannot watch: the save // Asked to watch a service the daemon cannot watch: the save
// stands, the watch verdict says why not. // stands, the watch verdict says why not.
}
Ok(saved) Ok(saved)
} }
+3 -3
View File
@@ -669,12 +669,12 @@ pub fn discover(
/// The config file's model seeds llama's fallback, as discovery always /// The config file's model seeds llama's fallback, as discovery always
/// has: it names the deployment's local model when it names one at all. /// has: it names the deployment's local model when it names one at all.
fn seed_llama_model(backend: &mut Backend, config: &crate::config::ClawConfig) { fn seed_llama_model(backend: &mut Backend, config: &crate::config::ClawConfig) {
if backend.kind == "llama-cpp" { if backend.kind == "llama-cpp"
if let Some(model) = &config.model { && let Some(model) = &config.model
{
backend.default_model = model.clone(); backend.default_model = model.clone();
} }
} }
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
+7 -7
View File
@@ -320,21 +320,21 @@ impl ClawConfig {
// The agent token's safety is that it is scoped; making it the // The agent token's safety is that it is scoped; making it the
// human token silently unscopes everything the model's shell // human token silently unscopes everything the model's shell
// holds. Boot refuses the configuration instead. // holds. Boot refuses the configuration instead.
if let (Some(token), Some(agent_token)) = (&self.token, &self.agent_token) { if let (Some(token), Some(agent_token)) = (&self.token, &self.agent_token)
if !token.is_empty() && token == agent_token { && !token.is_empty()
&& token == agent_token
{
return Err(ConfigError::SameAgentToken); return Err(ConfigError::SameAgentToken);
} }
}
// The ingest credential's safety is that it is write-only and // The ingest credential's safety is that it is write-only and
// one route deep; a value shared with a wider class silently // one route deep; a value shared with a wider class silently
// widens it, so boot refuses the collision with either token. // widens it, so boot refuses the collision with either token.
if let Some(ingest_token) = self.ingest_token.as_deref().filter(|t| !t.is_empty()) { if let Some(ingest_token) = self.ingest_token.as_deref().filter(|t| !t.is_empty())
if Some(ingest_token) == self.token.as_deref() && (Some(ingest_token) == self.token.as_deref()
|| Some(ingest_token) == self.agent_token.as_deref() || Some(ingest_token) == self.agent_token.as_deref())
{ {
return Err(ConfigError::IngestTokenCollision); return Err(ConfigError::IngestTokenCollision);
} }
}
Ok(()) Ok(())
} }
} }
+3 -3
View File
@@ -349,15 +349,15 @@ pub async fn wait_for_resolution(
) -> WaitOutcome { ) -> WaitOutcome {
let deadline = tokio::time::Instant::now() + budget; let deadline = tokio::time::Instant::now() + budget;
loop { loop {
if let Ok(Some(consent)) = store.get(id) { if let Ok(Some(consent)) = store.get(id)
if let Some(granted) = consent.granted { && let Some(granted) = consent.granted
{
return if granted { return if granted {
WaitOutcome::Granted(consent.account_id) WaitOutcome::Granted(consent.account_id)
} else { } else {
WaitOutcome::Denied WaitOutcome::Denied
}; };
} }
}
let waiter = bridge.waiter(id); let waiter = bridge.waiter(id);
let remaining = deadline.saturating_duration_since(tokio::time::Instant::now()); let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());
match tokio::time::timeout(remaining, waiter.notified()).await { match tokio::time::timeout(remaining, waiter.notified()).await {
+6 -6
View File
@@ -1433,8 +1433,9 @@ async fn ingest(State(state): State<ClawState>, Json(body): Json<IngestBody>) ->
// `phone status` read cannot. A bare `phone:<device>` key is a // `phone status` read cannot. A bare `phone:<device>` key is a
// message on the device's resident key and dispatches like any // message on the device's resident key and dispatches like any
// resident key's. A store failure is logged, never fatal. // resident key's. A store failure is logged, never fatal.
if source == crate::phone::SOURCE { if source == crate::phone::SOURCE
if let Some((device, topic)) = crate::phone::phone_key_parts(key) { && let Some((device, topic)) = crate::phone::phone_key_parts(key)
{
if let Err(err) = state.phone.observe(device, topic, &body.payload) { if let Err(err) = state.phone.observe(device, topic, &body.payload) {
eprintln!("[claw] warning: phone state for {key} not stored: {err}"); eprintln!("[claw] warning: phone state for {key} not stored: {err}");
} }
@@ -1444,7 +1445,6 @@ async fn ingest(State(state): State<ClawState>, Json(body): Json<IngestBody>) ->
) )
.into_response(); .into_response();
} }
}
match state.ingest_external(source, key, body.payload) { match state.ingest_external(source, key, body.payload) {
Ok(result) => ( Ok(result) => (
StatusCode::ACCEPTED, StatusCode::ACCEPTED,
@@ -1761,14 +1761,14 @@ async fn providers_set_credentials(
} }
let kind = match state.backends().get(id) { let kind = match state.backends().get(id) {
Some(existing) => { Some(existing) => {
if let Some(kind) = body["kind"].as_str() { if let Some(kind) = body["kind"].as_str()
if kind != existing.kind { && kind != existing.kind
{
return Err(bad_request(format!( return Err(bad_request(format!(
"provider {id:?} is a {} backend, not {kind:?}", "provider {id:?} is a {} backend, not {kind:?}",
existing.kind existing.kind
))); )));
} }
}
existing.kind.clone() existing.kind.clone()
} }
None => match body["kind"].as_str() { None => match body["kind"].as_str() {
+3 -3
View File
@@ -142,13 +142,13 @@ impl IdentityStore {
]; ];
for (field, value, cap) in fields { for (field, value, cap) in fields {
let cleaned = value.as_deref().map(str::trim).filter(|v| !v.is_empty()); let cleaned = value.as_deref().map(str::trim).filter(|v| !v.is_empty());
if let Some(value) = cleaned { if let Some(value) = cleaned
if value.chars().count() > cap { && value.chars().count() > cap
{
return Err(IdentityError::Backend(format!( return Err(IdentityError::Backend(format!(
"{field} is over {cap} characters" "{field} is over {cap} characters"
))); )));
} }
}
self.settings self.settings
.set( .set(
&text_key(field), &text_key(field),
+3 -3
View File
@@ -462,14 +462,14 @@ pub async fn wait_for_command_result(
) -> CommandOutcome { ) -> CommandOutcome {
let deadline = tokio::time::Instant::now() + budget; let deadline = tokio::time::Instant::now() + budget;
loop { loop {
if let Ok(Some(command)) = store.command_by_id(id) { if let Ok(Some(command)) = store.command_by_id(id)
if let Some(ok) = command.result_ok { && let Some(ok) = command.result_ok
{
return CommandOutcome::Confirmed { return CommandOutcome::Confirmed {
ok, ok,
detail: command.result_detail, detail: command.result_detail,
}; };
} }
}
let waiter = bridge.waiter(id); let waiter = bridge.waiter(id);
let remaining = deadline.saturating_duration_since(tokio::time::Instant::now()); let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());
match tokio::time::timeout(remaining, waiter.notified()).await { match tokio::time::timeout(remaining, waiter.notified()).await {
+3 -3
View File
@@ -149,14 +149,14 @@ impl ToolOp for ScheduleTask {
.as_deref() .as_deref()
.map(str::trim) .map(str::trim)
.filter(|session| !session.is_empty()); .filter(|session| !session.is_empty());
if let Some(session) = deliver_to { if let Some(session) = deliver_to
if !is_resident_key(session) { && !is_resident_key(session)
{
return Err(format!( return Err(format!(
"session must be a resident key (interactive:, task:, or phone:), got {session:?}" "session must be a resident key (interactive:, task:, or phone:), got {session:?}"
) )
.into()); .into());
} }
}
let record = match (args.at, args.every_secs) { let record = match (args.at, args.every_secs) {
(Some(at), None) => { (Some(at), None) => {
let at_millis = parse_at_millis(at)?; let at_millis = parse_at_millis(at)?;
@@ -234,22 +234,22 @@ fn vevent_blocks(raw: &str) -> Vec<Vec<ContentLine>> {
} }
"END" => { "END" => {
let component = line.value.trim().to_ascii_uppercase(); let component = line.value.trim().to_ascii_uppercase();
if component == "VEVENT" { if component == "VEVENT"
if let Some(block) = current.take() { && let Some(block) = current.take()
{
blocks.push(block); blocks.push(block);
} }
}
stack.pop(); stack.pop();
} }
_ => { _ => {
if stack.last().map(String::as_str) == Some("VEVENT") { if stack.last().map(String::as_str) == Some("VEVENT")
if let Some(block) = current.as_mut() { && let Some(block) = current.as_mut()
{
block.push(line); block.push(line);
} }
} }
} }
} }
}
blocks blocks
} }
@@ -755,11 +755,11 @@ fn expand_rule(
if walked > MAX_CANDIDATES { if walked > MAX_CANDIDATES {
return false; return false;
} }
if let Some(until) = rule.until { if let Some(until) = rule.until
if start > until { && start > until
{
return false; return false;
} }
}
if start > window.to { if start > window.to {
return false; return false;
} }
@@ -398,11 +398,11 @@ fn review_event(
Some(timestamp) => timestamp, Some(timestamp) => timestamp,
None => return Ok(None), None => return Ok(None),
}; };
if let Some(since) = since { if let Some(since) = since
if timestamp < *since { && timestamp < *since
{
return Ok(None); return Ok(None);
} }
}
let id = required(row.id, "review id")?; let id = required(row.id, "review id")?;
Ok(Some(ForgeEvent { Ok(Some(ForgeEvent {
id: format!("gitea:review:{id}"), id: format!("gitea:review:{id}"),
@@ -577,11 +577,11 @@ impl Forge for GiteaForge {
]; ];
for row in self.paged::<WirePull>(&pulls_path, &query).await? { for row in self.paged::<WirePull>(&pulls_path, &query).await? {
let updated = required(row.updated_at.clone(), "pull updated_at")?; let updated = required(row.updated_at.clone(), "pull updated_at")?;
if let Some(since) = since { if let Some(since) = since
if updated < *since { && updated < *since
{
continue; continue;
} }
}
let number = required(row.number, "pull number")?; let number = required(row.number, "pull number")?;
if let Some(event) = pull_event(&row, repo)? { if let Some(event) = pull_event(&row, repo)? {
events.push(event); events.push(event);
@@ -400,11 +400,11 @@ fn review_event(
} }
// A review without a submission time was never submitted. // A review without a submission time was never submitted.
let timestamp = required(row.submitted_at.clone(), "review submitted_at")?; let timestamp = required(row.submitted_at.clone(), "review submitted_at")?;
if let Some(since) = since { if let Some(since) = since
if timestamp < *since { && timestamp < *since
{
return Ok(None); return Ok(None);
} }
}
let id = required(row.id, "review id")?; let id = required(row.id, "review id")?;
Ok(Some(ForgeEvent { Ok(Some(ForgeEvent {
id: format!("github:review:{id}"), id: format!("github:review:{id}"),
@@ -382,11 +382,11 @@ fn note_event(
return Ok(None); return Ok(None);
} }
let timestamp = required(row.created_at.clone(), "note created_at")?; let timestamp = required(row.created_at.clone(), "note created_at")?;
if let Some(since) = since { if let Some(since) = since
if timestamp < *since { && timestamp < *since
{
return Ok(None); return Ok(None);
} }
}
let id = required(row.id, "note id")?; let id = required(row.id, "note id")?;
Ok(Some(ForgeEvent { Ok(Some(ForgeEvent {
id: format!("gitlab:note:{id}"), id: format!("gitlab:note:{id}"),