From 427bbf3193b387cbb0e009e80d6252b73ec05ca9 Mon Sep 17 00:00:00 2001 From: Rahix Date: Thu, 5 Mar 2026 22:01:58 +0100 Subject: [PATCH] Fix clippy issues --- src/collect.rs | 10 +++++----- src/context.rs | 4 ++-- src/reminder.rs | 30 +++++++++++------------------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/collect.rs b/src/collect.rs index 9113b7f..5f95f96 100644 --- a/src/collect.rs +++ b/src/collect.rs @@ -217,7 +217,7 @@ async fn list_all_issues(ctx: &crate::Context) -> anyhow::Result> { ) .all() .await - .with_context(|| format!("Failed fetching issue list"))?; + .context("Failed fetching issue list")?; Ok(issues) } @@ -231,11 +231,11 @@ trait IssueExt { impl IssueExt for Issue { fn get_number(&self) -> anyhow::Result { - Ok(self + self .number .context("Missing issue number")? .try_into() - .context("Failed converting issue number to u32")?) + .context("Failed converting issue number to u32") } fn get_title(&self) -> anyhow::Result { @@ -243,13 +243,13 @@ impl IssueExt for Issue { } fn get_state(&self) -> anyhow::Result { - Ok(self.state.context("Issue has no state")?) + self.state.context("Issue has no state") } fn get_label_names(&self) -> anyhow::Result> { let labels = self.labels.as_ref().context("Issue without labels list")?; let label_names = labels - .into_iter() + .iter() .map(|label| label.name.as_ref().context("Label without name").cloned()) .collect::>>()?; Ok(label_names) diff --git a/src/context.rs b/src/context.rs index 2ee3933..8a9bf23 100644 --- a/src/context.rs +++ b/src/context.rs @@ -56,10 +56,10 @@ impl Context { format!("Could not split repo slug {repo_with_owner:?} into owner and repo") })?; - let server_url = url::Url::parse(&server_url).context("Failed parsing server URL")?; + let server_url = url::Url::parse(server_url).context("Failed parsing server URL")?; let repo_url = server_url - .join(&repo_with_owner) + .join(repo_with_owner) .context("Failed to build server + repo URL")?; let repo_auth_url = { let mut repo_auth_url = repo_url.clone(); diff --git a/src/reminder.rs b/src/reminder.rs index 8d102c1..2c4da90 100644 --- a/src/reminder.rs +++ b/src/reminder.rs @@ -66,8 +66,8 @@ pub async fn remind_all_tasks(ctx: &crate::Context, tasks: &[task::Task]) -> any Ok(()) } -pub const SIGNATURE_BASIC: &'static str = "\\[TaskBot Comment\\]"; -pub const SIGNATURE_URGENT: &'static str = "\\[TaskBot Comment (Urgent)\\]"; +pub const SIGNATURE_BASIC: &str = "\\[TaskBot Comment\\]"; +pub const SIGNATURE_URGENT: &str = "\\[TaskBot Comment (Urgent)\\]"; async fn remind_task( ctx: &crate::Context, @@ -76,22 +76,14 @@ async fn remind_task( batching_interval: BatchingInterval, ) -> anyhow::Result<()> { let body = match (reminder_type, batching_interval) { - (ReminderType::Basic, BatchingInterval::Monthly) => format!( - "\ -Beep boop. This task is due this month, go take care of it!" - ), - (ReminderType::Basic, BatchingInterval::Weekly) => format!( - "\ -Beep boop. This task is due this week, go take care of it!" - ), - (ReminderType::Basic, BatchingInterval::OnTheDay) => format!( - "\ -Beep boop. This task is due today, go take care of it!" - ), - (ReminderType::Urgent, _) => format!( - "\ -Hello again. This task is overdue, please take care of it ASAP!" - ), + (ReminderType::Basic, BatchingInterval::Monthly) => "\ +Beep boop. This task is due this month, go take care of it!".to_string(), + (ReminderType::Basic, BatchingInterval::Weekly) => "\ +Beep boop. This task is due this week, go take care of it!".to_string(), + (ReminderType::Basic, BatchingInterval::OnTheDay) => "\ +Beep boop. This task is due today, go take care of it!".to_string(), + (ReminderType::Urgent, _) => "\ +Hello again. This task is overdue, please take care of it ASAP!".to_string(), }; let signature = match reminder_type { @@ -107,7 +99,7 @@ Hello again. This task is overdue, please take care of it ASAP!" &ctx.repo, task.issue_number.into(), forgejo_api::structs::CreateIssueCommentOption { - body: body, + body, updated_at: None, }, )