fix #265: resolve all remaining clippy warnings (cast, too_many_lines, doc nits)

This commit is contained in:
damocles 2026-05-22 19:02:11 +02:00
parent 30d82148e0
commit 484cea62c7
12 changed files with 95 additions and 86 deletions

View file

@ -22,6 +22,7 @@
//! are silently marked read — the agent already knows it opened them.
//! - Comment notifications where the comment author matches this agent's own
//! forge login are silently marked read.
//!
//! Own login is fetched once at startup via `GET /user` and cached for the
//! lifetime of the polling loop.
//!
@ -32,6 +33,7 @@
//! generic `[comment on PR #N repo]` so agents can action it immediately.
use std::collections::HashSet;
use std::fmt::Write as _;
use std::path::{Path, PathBuf};
use std::time::Duration;
@ -209,6 +211,7 @@ fn review_state_label(state: &str) -> Option<&str> {
///
/// Number is extracted from `html_url` last path segment before any `#`.
/// Repo slug (`owner/name`) is always included — agents may watch multiple repos.
#[allow(clippy::too_many_lines)] // multiple notification types handled in one place by design
async fn format_notification(
client: &reqwest::Client,
token: &str,
@ -329,9 +332,9 @@ async fn format_notification(
let kind = format!("PR {review_label}{num}{repo}");
let mut out = format!("[{kind}] {title}\nurl: {url}");
if body_text.is_empty() {
out.push_str(&format!("\n\nreviewer: {author}"));
write!(out, "\n\nreviewer: {author}").ok();
} else {
out.push_str(&format!("\n\n{author}: {}", truncate(body_text, BODY_TRUNCATE)));
write!(out, "\n\n{author}: {}", truncate(body_text, BODY_TRUNCATE)).ok();
}
out.push_str(&meta_suffix);
Some(out)
@ -449,15 +452,12 @@ async fn poll_once(
debug!(count = notifications.len(), "forge_notify: delivering notifications");
for notif in &notifications {
let id = match notif["id"].as_u64() {
Some(n) => n,
None => continue,
};
let Some(id) = notif["id"].as_u64() else { continue };
let body_opt = format_notification(client, token, notif, own_login).await;
// None means self-echo — mark read silently, no delivery.
let body = if let Some(b) = body_opt { b } else {
let Some(body) = body_opt else {
mark_read(client, forge_url, token, id).await;
continue;
};