From 3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 Mon Sep 17 00:00:00 2001 From: aur-build Date: Sun, 22 Nov 2026 10:36:24 +0000 Subject: rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three. --- src/db/staleness.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src/db/staleness.rs') diff --git a/src/db/staleness.rs b/src/db/staleness.rs index 59fccee..58be227 100644 --- a/src/db/staleness.rs +++ b/src/db/staleness.rs @@ -1,6 +1,6 @@ use rusqlite::{params, OptionalExtension}; -use crate::db::*; +use crate::db::{Db, Writer}; use crate::error::Result; use crate::time; @@ -33,11 +33,7 @@ pub fn served_vs_offered_pkgvers(db: &Db) -> Result(0)?, - r.get::<_, String>(1)?, - r.get::<_, Option>(2)?.unwrap_or_default(), - )) + Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?, r.get::<_, Option>(2)?.unwrap_or_default())) })?; Ok(rows.collect::<::rusqlite::Result>>()?) }) @@ -63,10 +59,12 @@ pub fn index_recipes(db: &Db) -> Result> { pub fn approval_note(db: &Db, approval_id: i64) -> Result { db.read(|c| { - c.query_row("SELECT COALESCE(note,'') FROM approval WHERE id=?1", params![approval_id], |r| r.get::<_, String>(0)) - .optional() - .map(|o| o.unwrap_or_default()) - .map_err(Into::into) + c.query_row("SELECT COALESCE(note,'') FROM approval WHERE id=?1", params![approval_id], |r| { + r.get::<_, String>(0) + }) + .optional() + .map(std::option::Option::unwrap_or_default) + .map_err(Into::into) }) } @@ -77,7 +75,6 @@ pub fn candidate_snapshot_id(db: &Db, candidate_id: i64) -> Result> }) } - pub fn put_source_cache(writer: &Writer, url: &str, digest: &str, size: u64, path: &str) -> Result<()> { let (u, d, p) = (url.to_string(), digest.to_string(), path.to_string()); let at = time::now(); @@ -93,11 +90,9 @@ pub fn put_source_cache(writer: &Writer, url: &str, digest: &str, size: u64, pat pub fn source_cache_path(db: &Db, url: &str, digest: &str) -> Result> { db.read(|c| { - Ok(c.query_row( - "SELECT path FROM source_cache WHERE url=?1 AND digest=?2", - params![url, digest], - |r| r.get::<_, String>(0), - ) + Ok(c.query_row("SELECT path FROM source_cache WHERE url=?1 AND digest=?2", params![url, digest], |r| { + r.get::<_, String>(0) + }) .optional()?) }) } @@ -121,4 +116,3 @@ pub fn insert_artifact_in(tx: &rusqlite::Transaction<'_>, a: &NewArtifact<'_>) - )?; Ok(()) } - -- cgit v1.2.3