From 71e39c10958048b388fcefbcd713ddce2de84366 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Mon, 23 Feb 2026 04:47:50 +0700 Subject: [PATCH] Fix clippy warnings: remove unused async and format code - Remove async from update_health_metrics since it doesn't await - Remove .await from call site in alive handler - Add clippy allow attributes for Rocket handler - Apply rustfmt formatting --- src/api/identity.rs | 10 +++++++--- src/api/metrics.rs | 4 ++-- src/api/web.rs | 3 ++- src/metrics.rs | 8 +++----- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/api/identity.rs b/src/api/identity.rs index 945b6838..2053ba5d 100644 --- a/src/api/identity.rs +++ b/src/api/identity.rs @@ -30,9 +30,9 @@ use crate::{ DbConn, }, error::MapResult, - mail, sso, + mail, metrics, sso, sso::{OIDCCode, OIDCCodeChallenge, OIDCCodeVerifier, OIDCState}, - util, CONFIG, metrics, + util, CONFIG, }; pub fn routes() -> Vec { @@ -106,7 +106,11 @@ async fn login( }; // Record authentication metrics - let auth_status = if login_result.is_ok() { "success" } else { "failed" }; + let auth_status = if login_result.is_ok() { + "success" + } else { + "failed" + }; metrics::increment_auth_attempts(&auth_method, auth_status); if let Some(user_id) = user_id { diff --git a/src/api/metrics.rs b/src/api/metrics.rs index f5d1a563..3723e831 100644 --- a/src/api/metrics.rs +++ b/src/api/metrics.rs @@ -103,7 +103,7 @@ async fn get_metrics(_token: MetricsToken, mut conn: DbConn) -> Result = std::sync::OnceLock::new(); @@ -117,4 +117,4 @@ pub async fn update_health_metrics(_conn: &mut DbConn) { } #[cfg(not(feature = "enable_metrics"))] -pub async fn update_health_metrics(_conn: &mut DbConn) {} +pub fn update_health_metrics(_conn: &mut DbConn) {} diff --git a/src/api/web.rs b/src/api/web.rs index 3c33a779..3ef43d6d 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -179,9 +179,10 @@ async fn attachments(cipher_id: CipherId, file_id: AttachmentId, token: String) // We use DbConn here to let the alive healthcheck also verify the database connection. use crate::db::DbConn; #[get("/alive")] +#[allow(clippy::let_unit_value, clippy::unused_async)] async fn alive(mut conn: DbConn) -> Json { // Update basic health metrics if metrics are enabled - let _ = crate::api::metrics::update_health_metrics(&mut conn).await; + crate::api::metrics::update_health_metrics(&mut conn); now() } diff --git a/src/metrics.rs b/src/metrics.rs index 70a67558..cdaf07e0 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -4,14 +4,14 @@ use once_cell::sync::Lazy; #[cfg(feature = "enable_metrics")] use prometheus::{ - register_gauge_vec, register_histogram_vec, register_int_counter_vec, register_int_gauge_vec, - Encoder, GaugeVec, HistogramVec, IntCounterVec, IntGaugeVec, TextEncoder, + register_gauge_vec, register_histogram_vec, register_int_counter_vec, register_int_gauge_vec, Encoder, GaugeVec, + HistogramVec, IntCounterVec, IntGaugeVec, TextEncoder, }; use crate::{db::DbConn, error::Error, CONFIG}; -use std::time::SystemTime; #[cfg(feature = "enable_metrics")] use std::sync::{Arc, RwLock}; +use std::time::SystemTime; #[cfg(feature = "enable_metrics")] use std::time::UNIX_EPOCH; @@ -138,8 +138,6 @@ pub fn increment_auth_attempts(method: &str, status: &str) { AUTH_ATTEMPTS_TOTAL.with_label_values(&[method, status]).inc(); } - - /// Update active user sessions #[cfg(feature = "enable_metrics")] pub fn update_user_sessions(user_type: &str, count: i64) {