diff --git a/crates/rhema-claw/src/accounts_tools.rs b/crates/rhema-claw/src/accounts_tools.rs index 7305f7f..4664dfe 100644 --- a/crates/rhema-claw/src/accounts_tools.rs +++ b/crates/rhema-claw/src/accounts_tools.rs @@ -132,16 +132,14 @@ pub fn save_account( forge_known: forge.is_some(), watch_added: false, }; - if watch { - if let Some(kind) = forge { - let host = saved.account.url.as_deref().filter(|url| !url.is_empty()); - saved.watch_added = watches - .add_account_watch(kind.name(), host, &saved.account.id) - .map_err(|err| err.to_string())?; - } - // Asked to watch a service the daemon cannot watch: the save - // stands, the watch verdict says why not. + if watch && let Some(kind) = forge { + let host = saved.account.url.as_deref().filter(|url| !url.is_empty()); + saved.watch_added = watches + .add_account_watch(kind.name(), host, &saved.account.id) + .map_err(|err| err.to_string())?; } + // Asked to watch a service the daemon cannot watch: the save + // stands, the watch verdict says why not. Ok(saved) } diff --git a/crates/rhema-claw/src/backends.rs b/crates/rhema-claw/src/backends.rs index 58b17b6..5fa25a3 100644 --- a/crates/rhema-claw/src/backends.rs +++ b/crates/rhema-claw/src/backends.rs @@ -669,10 +669,10 @@ pub fn discover( /// 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. fn seed_llama_model(backend: &mut Backend, config: &crate::config::ClawConfig) { - if backend.kind == "llama-cpp" { - if let Some(model) = &config.model { - backend.default_model = model.clone(); - } + if backend.kind == "llama-cpp" + && let Some(model) = &config.model + { + backend.default_model = model.clone(); } } diff --git a/crates/rhema-claw/src/config.rs b/crates/rhema-claw/src/config.rs index 78a16fa..cb3f581 100644 --- a/crates/rhema-claw/src/config.rs +++ b/crates/rhema-claw/src/config.rs @@ -320,20 +320,20 @@ impl ClawConfig { // The agent token's safety is that it is scoped; making it the // human token silently unscopes everything the model's shell // holds. Boot refuses the configuration instead. - if let (Some(token), Some(agent_token)) = (&self.token, &self.agent_token) { - if !token.is_empty() && token == agent_token { - return Err(ConfigError::SameAgentToken); - } + if let (Some(token), Some(agent_token)) = (&self.token, &self.agent_token) + && !token.is_empty() + && token == agent_token + { + return Err(ConfigError::SameAgentToken); } // The ingest credential's safety is that it is write-only and // one route deep; a value shared with a wider class silently // 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 Some(ingest_token) == self.token.as_deref() - || Some(ingest_token) == self.agent_token.as_deref() - { - return Err(ConfigError::IngestTokenCollision); - } + if let Some(ingest_token) = self.ingest_token.as_deref().filter(|t| !t.is_empty()) + && (Some(ingest_token) == self.token.as_deref() + || Some(ingest_token) == self.agent_token.as_deref()) + { + return Err(ConfigError::IngestTokenCollision); } Ok(()) } diff --git a/crates/rhema-claw/src/consents.rs b/crates/rhema-claw/src/consents.rs index cb79ddb..b71e4cf 100644 --- a/crates/rhema-claw/src/consents.rs +++ b/crates/rhema-claw/src/consents.rs @@ -349,14 +349,14 @@ pub async fn wait_for_resolution( ) -> WaitOutcome { let deadline = tokio::time::Instant::now() + budget; loop { - if let Ok(Some(consent)) = store.get(id) { - if let Some(granted) = consent.granted { - return if granted { - WaitOutcome::Granted(consent.account_id) - } else { - WaitOutcome::Denied - }; - } + if let Ok(Some(consent)) = store.get(id) + && let Some(granted) = consent.granted + { + return if granted { + WaitOutcome::Granted(consent.account_id) + } else { + WaitOutcome::Denied + }; } let waiter = bridge.waiter(id); let remaining = deadline.saturating_duration_since(tokio::time::Instant::now()); diff --git a/crates/rhema-claw/src/http.rs b/crates/rhema-claw/src/http.rs index 28c178b..4e4bc8b 100644 --- a/crates/rhema-claw/src/http.rs +++ b/crates/rhema-claw/src/http.rs @@ -1433,17 +1433,17 @@ async fn ingest(State(state): State, Json(body): Json) -> // `phone status` read cannot. A bare `phone:` key is a // message on the device's resident key and dispatches like any // resident key's. A store failure is logged, never fatal. - if source == crate::phone::SOURCE { - if let Some((device, topic)) = crate::phone::phone_key_parts(key) { - if let Err(err) = state.phone.observe(device, topic, &body.payload) { - eprintln!("[claw] warning: phone state for {key} not stored: {err}"); - } - return ( - StatusCode::ACCEPTED, - Json(json!({ "ingested": "observed" })), - ) - .into_response(); + if source == crate::phone::SOURCE + && let Some((device, topic)) = crate::phone::phone_key_parts(key) + { + if let Err(err) = state.phone.observe(device, topic, &body.payload) { + eprintln!("[claw] warning: phone state for {key} not stored: {err}"); } + return ( + StatusCode::ACCEPTED, + Json(json!({ "ingested": "observed" })), + ) + .into_response(); } match state.ingest_external(source, key, body.payload) { Ok(result) => ( @@ -1761,13 +1761,13 @@ async fn providers_set_credentials( } let kind = match state.backends().get(id) { Some(existing) => { - if let Some(kind) = body["kind"].as_str() { - if kind != existing.kind { - return Err(bad_request(format!( - "provider {id:?} is a {} backend, not {kind:?}", - existing.kind - ))); - } + if let Some(kind) = body["kind"].as_str() + && kind != existing.kind + { + return Err(bad_request(format!( + "provider {id:?} is a {} backend, not {kind:?}", + existing.kind + ))); } existing.kind.clone() } diff --git a/crates/rhema-claw/src/identity.rs b/crates/rhema-claw/src/identity.rs index f92fa74..f75a4cd 100644 --- a/crates/rhema-claw/src/identity.rs +++ b/crates/rhema-claw/src/identity.rs @@ -142,12 +142,12 @@ impl IdentityStore { ]; for (field, value, cap) in fields { let cleaned = value.as_deref().map(str::trim).filter(|v| !v.is_empty()); - if let Some(value) = cleaned { - if value.chars().count() > cap { - return Err(IdentityError::Backend(format!( - "{field} is over {cap} characters" - ))); - } + if let Some(value) = cleaned + && value.chars().count() > cap + { + return Err(IdentityError::Backend(format!( + "{field} is over {cap} characters" + ))); } self.settings .set( diff --git a/crates/rhema-claw/src/phone.rs b/crates/rhema-claw/src/phone.rs index 553a83a..94ca309 100644 --- a/crates/rhema-claw/src/phone.rs +++ b/crates/rhema-claw/src/phone.rs @@ -462,13 +462,13 @@ pub async fn wait_for_command_result( ) -> CommandOutcome { let deadline = tokio::time::Instant::now() + budget; loop { - if let Ok(Some(command)) = store.command_by_id(id) { - if let Some(ok) = command.result_ok { - return CommandOutcome::Confirmed { - ok, - detail: command.result_detail, - }; - } + if let Ok(Some(command)) = store.command_by_id(id) + && let Some(ok) = command.result_ok + { + return CommandOutcome::Confirmed { + ok, + detail: command.result_detail, + }; } let waiter = bridge.waiter(id); let remaining = deadline.saturating_duration_since(tokio::time::Instant::now()); diff --git a/crates/rhema-claw/src/task_tools.rs b/crates/rhema-claw/src/task_tools.rs index fd382b8..11a0957 100644 --- a/crates/rhema-claw/src/task_tools.rs +++ b/crates/rhema-claw/src/task_tools.rs @@ -149,13 +149,13 @@ impl ToolOp for ScheduleTask { .as_deref() .map(str::trim) .filter(|session| !session.is_empty()); - if let Some(session) = deliver_to { - if !is_resident_key(session) { - return Err(format!( - "session must be a resident key (interactive:, task:, or phone:), got {session:?}" - ) - .into()); - } + if let Some(session) = deliver_to + && !is_resident_key(session) + { + return Err(format!( + "session must be a resident key (interactive:, task:, or phone:), got {session:?}" + ) + .into()); } let record = match (args.at, args.every_secs) { (Some(at), None) => { diff --git a/integrations/rhema-calendar-integration/src/ics.rs b/integrations/rhema-calendar-integration/src/ics.rs index 04fb6a3..232fe50 100644 --- a/integrations/rhema-calendar-integration/src/ics.rs +++ b/integrations/rhema-calendar-integration/src/ics.rs @@ -234,18 +234,18 @@ fn vevent_blocks(raw: &str) -> Vec> { } "END" => { let component = line.value.trim().to_ascii_uppercase(); - if component == "VEVENT" { - if let Some(block) = current.take() { - blocks.push(block); - } + if component == "VEVENT" + && let Some(block) = current.take() + { + blocks.push(block); } stack.pop(); } _ => { - if stack.last().map(String::as_str) == Some("VEVENT") { - if let Some(block) = current.as_mut() { - block.push(line); - } + if stack.last().map(String::as_str) == Some("VEVENT") + && let Some(block) = current.as_mut() + { + block.push(line); } } } @@ -755,10 +755,10 @@ fn expand_rule( if walked > MAX_CANDIDATES { return false; } - if let Some(until) = rule.until { - if start > until { - return false; - } + if let Some(until) = rule.until + && start > until + { + return false; } if start > window.to { return false; diff --git a/integrations/rhema-forge-integration/src/gitea.rs b/integrations/rhema-forge-integration/src/gitea.rs index 635bea1..82fa063 100644 --- a/integrations/rhema-forge-integration/src/gitea.rs +++ b/integrations/rhema-forge-integration/src/gitea.rs @@ -398,10 +398,10 @@ fn review_event( Some(timestamp) => timestamp, None => return Ok(None), }; - if let Some(since) = since { - if timestamp < *since { - return Ok(None); - } + if let Some(since) = since + && timestamp < *since + { + return Ok(None); } let id = required(row.id, "review id")?; Ok(Some(ForgeEvent { @@ -577,10 +577,10 @@ impl Forge for GiteaForge { ]; for row in self.paged::(&pulls_path, &query).await? { let updated = required(row.updated_at.clone(), "pull updated_at")?; - if let Some(since) = since { - if updated < *since { - continue; - } + if let Some(since) = since + && updated < *since + { + continue; } let number = required(row.number, "pull number")?; if let Some(event) = pull_event(&row, repo)? { diff --git a/integrations/rhema-forge-integration/src/github.rs b/integrations/rhema-forge-integration/src/github.rs index 46be658..baf5c86 100644 --- a/integrations/rhema-forge-integration/src/github.rs +++ b/integrations/rhema-forge-integration/src/github.rs @@ -400,10 +400,10 @@ fn review_event( } // A review without a submission time was never submitted. let timestamp = required(row.submitted_at.clone(), "review submitted_at")?; - if let Some(since) = since { - if timestamp < *since { - return Ok(None); - } + if let Some(since) = since + && timestamp < *since + { + return Ok(None); } let id = required(row.id, "review id")?; Ok(Some(ForgeEvent { diff --git a/integrations/rhema-forge-integration/src/gitlab.rs b/integrations/rhema-forge-integration/src/gitlab.rs index 8aa264f..6af4adf 100644 --- a/integrations/rhema-forge-integration/src/gitlab.rs +++ b/integrations/rhema-forge-integration/src/gitlab.rs @@ -382,10 +382,10 @@ fn note_event( return Ok(None); } let timestamp = required(row.created_at.clone(), "note created_at")?; - if let Some(since) = since { - if timestamp < *since { - return Ok(None); - } + if let Some(since) = since + && timestamp < *since + { + return Ok(None); } let id = required(row.id, "note id")?; Ok(Some(ForgeEvent {