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/review/risk.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/review/risk.rs') diff --git a/src/review/risk.rs b/src/review/risk.rs index e48ca24..4c9575f 100644 --- a/src/review/risk.rs +++ b/src/review/risk.rs @@ -1,4 +1,8 @@ -use crate::db::{self, model::*, Db}; +use crate::db::{ + self, + model::{Recipe, ReleaseRow, SourceDigest, UpstreamPin}, + Db, +}; use crate::error::Result; use crate::pkgver; @@ -22,8 +26,17 @@ pub mod level { const FETCHING_BUILD_TOOLS: &[&str] = &["cargo", "npm", "go", "pip", "python", "ruby", "deno", "rust", "nodejs"]; const BUILD_SYSTEM_FILES: &[&str] = &[ - "Cargo.toml", "Cargo.lock", "package.json", "setup.py", "pyproject.toml", "Makefile", "CMakeLists.txt", - "meson.build", "go.mod", "Gemfile", "build.gradle", + "Cargo.toml", + "Cargo.lock", + "package.json", + "setup.py", + "pyproject.toml", + "Makefile", + "CMakeLists.txt", + "meson.build", + "go.mod", + "Gemfile", + "build.gradle", ]; #[derive(Debug, Clone, Default)] @@ -32,8 +45,7 @@ pub(crate) struct Assessment { pub signals: Vec, } -impl Assessment { -} +impl Assessment {} pub(crate) fn assess( db: &Db, @@ -94,7 +106,7 @@ pub(crate) fn assess( } fn accepted_pins(accepted: Option<&ReleaseRow>) -> Vec { - accepted.map(|a| a.pins()).unwrap_or_default() + accepted.map_or_default(super::super::db::model::ReleaseRow::pins) } fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { @@ -120,9 +132,7 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { for (i, sum) in new.sha256sums.iter().enumerate() { if sum.eq_ignore_ascii_case("SKIP") { match old.sha256sums.get(i) { - Some(prev) if prev != "SKIP" && !prev.is_empty() => { - s.add(&format!("sums-to-skip:{i}"), level::HIGH) - } + Some(prev) if prev != "SKIP" && !prev.is_empty() => s.add(&format!("sums-to-skip:{i}"), level::HIGH), _ => {} } } @@ -172,7 +182,7 @@ fn upstream_touches_build_system(cfg: &crate::config::Config, from: &str, to: &s return false; } let range = format!("{from}..{to}"); - for dir in std::fs::read_dir(&cache).into_iter().flatten().filter_map(|d| d.ok()) { + for dir in std::fs::read_dir(&cache).into_iter().flatten().filter_map(std::result::Result::ok) { let path = dir.path(); if let Ok(files) = crate::git::git(Some(&path), &["diff", "--name-only", &range]) { if files.lines().any(|f| BUILD_SYSTEM_FILES.iter().any(|b| f.ends_with(b))) { -- cgit v1.2.3