From ec81d3228b9caaa6f9665904f63abd8e153a7e91 Mon Sep 17 00:00:00 2001 From: GW_MC <72297530+GWMCwing@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:25:55 +0800 Subject: [PATCH] fix clippy warnings --- .vscode/settings.json | 11 ++++++++++- apps/api/src/routes/api/auth.rs | 5 +---- apps/api/src/routes/api/auth/login.rs | 2 +- apps/api/src/routes/api/restricted.rs | 2 +- apps/api/src/services/auth/authentication.rs | 8 ++++++++ .../auth/authentication/strategies/password.rs | 10 +++++----- apps/api/src/services/auth/user.rs | 10 ++++++++++ 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9029dfa..473d1d0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,12 @@ { - "cSpell.words": ["YANPM"] + "cSpell.words": ["chrono", "jsonwebtoken", "oneshot", "utoipa", "YANPM"], + "sqltools.useNodeRuntime": true, + "sqltools.connections": [ + { + "previewLimit": 50, + "driver": "SQLite", + "database": "${workspaceFolder:yet-another-nginx-proxy-manager}/apps/container/generated/sqlite/sqlite.db", + "name": "YANPM" + } + ] } diff --git a/apps/api/src/routes/api/auth.rs b/apps/api/src/routes/api/auth.rs index 2242a44..a76b52d 100644 --- a/apps/api/src/routes/api/auth.rs +++ b/apps/api/src/routes/api/auth.rs @@ -3,10 +3,7 @@ pub mod login; use std::sync::Arc; -use axum::{ - Router, - routing::{get, post}, -}; +use axum::{Router, routing::post}; use crate::routes::AppState; diff --git a/apps/api/src/routes/api/auth/login.rs b/apps/api/src/routes/api/auth/login.rs index a2abf66..06f16c4 100644 --- a/apps/api/src/routes/api/auth/login.rs +++ b/apps/api/src/routes/api/auth/login.rs @@ -92,7 +92,7 @@ pub async fn login(State(state): State>, Json(payload): Json resp, Err(e) => { error!("Error building response: {}", e); - return (StatusCode::INTERNAL_SERVER_ERROR).into_response(); + (StatusCode::INTERNAL_SERVER_ERROR).into_response() } } } diff --git a/apps/api/src/routes/api/restricted.rs b/apps/api/src/routes/api/restricted.rs index 2372184..a5ec9f4 100644 --- a/apps/api/src/routes/api/restricted.rs +++ b/apps/api/src/routes/api/restricted.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use axum::{Router, routing::get}; +use axum::Router; use crate::{middlewares::require_auth::require_auth, routes::AppState}; diff --git a/apps/api/src/services/auth/authentication.rs b/apps/api/src/services/auth/authentication.rs index a7c1096..131486e 100644 --- a/apps/api/src/services/auth/authentication.rs +++ b/apps/api/src/services/auth/authentication.rs @@ -14,6 +14,7 @@ use tokio::sync::RwLock; use crate::errors::service_error::ServiceError; // Number of requests between invalidation cache cleanups +#[allow(dead_code)] // TODO: remove when used const INVALIDATE_CACHE_CLEANUP_INTERVAL_REQUESTS: usize = 100; // Cleanup every 100 for invalidation checks #[derive(Serialize, Deserialize, Clone)] @@ -38,10 +39,15 @@ pub trait AuthenticationService: Send + Sync { token: &str, target_sub: Option, ) -> Result, ServiceError>; + #[allow(dead_code)] // TODO: remove when used async fn parse_jwt(&self, token: &str) -> Result; + #[allow(dead_code)] // TODO: remove when used async fn invalidate_jwt(&self, token: &str) -> Result<(), ServiceError>; + #[allow(dead_code)] // TODO: remove when used async fn refresh_jwt(&self, token: &str, duration_secs: u64) -> Result; + #[allow(dead_code)] // TODO: remove when used async fn logout(&self, token: &str) -> Result<(), ServiceError>; + #[allow(dead_code)] // TODO: remove when used async fn cleanup_invalidation_cache(&self); } @@ -54,7 +60,9 @@ struct InvalidationEntry { pub struct AuthenticationServiceImpl { secret: String, + #[allow(dead_code)] // TODO: remove when used invalidation_cache: Arc>>, + #[allow(dead_code)] // TODO: remove when used cache_cleanup_counter: Arc>, } diff --git a/apps/api/src/services/auth/authentication/strategies/password.rs b/apps/api/src/services/auth/authentication/strategies/password.rs index 167685c..ce7d794 100644 --- a/apps/api/src/services/auth/authentication/strategies/password.rs +++ b/apps/api/src/services/auth/authentication/strategies/password.rs @@ -68,7 +68,7 @@ impl PasswordStrategy { Ok(user.id) } - + #[allow(dead_code)] // TODO: remove when used pub async fn revoke_identity( &self, user_id: Uuid, @@ -126,7 +126,7 @@ impl PasswordStrategy { Ok(()) } - + #[allow(dead_code)] // TODO: remove when used pub async fn update_password( &self, user_id: Uuid, @@ -368,7 +368,7 @@ mod test { user_id: Uuid::new_v4(), email: None, provider: PASSWORD_PROVIDER.to_string(), - password_hash: Some("somehash".to_string()), + password_hash: Some("some_hash".to_string()), metadata: None, is_revoked: false, revoked_at: None, @@ -413,7 +413,7 @@ mod test { user_id, email: None, provider: PASSWORD_PROVIDER.to_string(), - password_hash: Some("oldhash".to_string()), + password_hash: Some("old_hash".to_string()), metadata: None, is_revoked: false, revoked_at: None, @@ -430,7 +430,7 @@ mod test { user_id, email: None, provider: PASSWORD_PROVIDER.to_string(), - password_hash: Some("newhash".to_string()), + password_hash: Some("new_hash".to_string()), metadata: None, is_revoked: false, revoked_at: None, diff --git a/apps/api/src/services/auth/user.rs b/apps/api/src/services/auth/user.rs index add0dbf..03703ac 100644 --- a/apps/api/src/services/auth/user.rs +++ b/apps/api/src/services/auth/user.rs @@ -17,11 +17,13 @@ pub trait UserService: Send + Sync { user_id: Uuid, tx: Option<&mut DatabaseTransaction>, ) -> Result; + #[allow(dead_code)] // TODO: remove when used async fn is_admin( &self, user_id: Uuid, tx: Option<&mut DatabaseTransaction>, ) -> Result; + #[allow(dead_code)] // TODO: remove when used async fn user_exists( &self, username: &str, @@ -32,12 +34,14 @@ pub trait UserService: Send + Sync { user: NewUser, tx: Option<&mut DatabaseTransaction>, ) -> Result; + #[allow(dead_code)] // TODO: remove when used async fn update_user( &self, user_id: Uuid, user: UpdateUser, tx: Option<&mut DatabaseTransaction>, ) -> Result; + #[allow(dead_code)] // TODO: remove when used async fn delete_user( &self, user_id: Uuid, @@ -47,7 +51,9 @@ pub trait UserService: Send + Sync { pub struct User { pub id: Uuid, + #[allow(dead_code)] // TODO: remove when used pub username: String, + #[allow(dead_code)] // TODO: remove when used pub is_admin: bool, } @@ -67,12 +73,16 @@ pub struct NewUser { } pub struct UpdateUser { + #[allow(dead_code)] // TODO: remove when used pub username: Option, + #[allow(dead_code)] // TODO: remove when used pub is_admin: Option, + #[allow(dead_code)] // TODO: remove when used pub is_active: Option, } impl UpdateUser { + #[allow(dead_code)] // TODO: remove when used fn apply_to_active_model(&self, model: &mut UserActiveModel) { if let Some(username) = &self.username { model.name = ActiveValue::Set(username.clone());