From b664ba578dd70301b9666fa9d895bb15e5bb89d3 Mon Sep 17 00:00:00 2001 From: n08i40k Date: Thu, 25 Sep 2025 03:42:34 +0400 Subject: [PATCH] chore(clippy): fix all clippy warnings --- .../provider-engels-polytechnic/src/parser/mod.rs | 2 +- src/routes/auth/shared.rs | 10 ---------- src/routes/auth/sign_in.rs | 2 +- src/utility/jwt.rs | 9 ++++----- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/providers/provider-engels-polytechnic/src/parser/mod.rs b/providers/provider-engels-polytechnic/src/parser/mod.rs index 4c9d8fc..07b3335 100644 --- a/providers/provider-engels-polytechnic/src/parser/mod.rs +++ b/providers/provider-engels-polytechnic/src/parser/mod.rs @@ -528,7 +528,7 @@ fn parse_name_and_subgroups(text: &str) -> Result { if result.is_none() { #[cfg(not(debug_assertions))] sentry::capture_message( - &*format!("Не удалось угадать тип пары '{}'!", extra), + &format!("Не удалось угадать тип пары '{}'!", extra), sentry::Level::Warning, ); diff --git a/src/routes/auth/shared.rs b/src/routes/auth/shared.rs index b5ee062..c987e16 100644 --- a/src/routes/auth/shared.rs +++ b/src/routes/auth/shared.rs @@ -2,16 +2,6 @@ use jsonwebtoken::errors::ErrorKind; use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode}; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Serialize)] -struct TokenData { - iis: String, - sub: i32, - app: i32, - exp: i32, - iat: i32, - jti: i32, -} - #[derive(Debug, Serialize, Deserialize)] struct Claims { sub: i32, diff --git a/src/routes/auth/sign_in.rs b/src/routes/auth/sign_in.rs index f8d0f6b..f8d9044 100644 --- a/src/routes/auth/sign_in.rs +++ b/src/routes/auth/sign_in.rs @@ -185,7 +185,7 @@ mod tests { id: Set(id.clone()), username: Set(username), password: Set(Some( - bcrypt::hash("example".to_string(), bcrypt::DEFAULT_COST).unwrap(), + bcrypt::hash("example", bcrypt::DEFAULT_COST).unwrap(), )), vk_id: Set(None), telegram_id: Set(None), diff --git a/src/utility/jwt.rs b/src/utility/jwt.rs index 511b687..621e63c 100644 --- a/src/utility/jwt.rs +++ b/src/utility/jwt.rs @@ -24,14 +24,13 @@ static ENCODING_KEY: LazyLock = LazyLock::new(|| { }); /// Token verification errors. -#[allow(dead_code)] #[derive(Debug)] pub enum Error { /// The token has a different signature. InvalidSignature, /// Token reading error. - InvalidToken(ErrorKind), + InvalidToken, /// Token expired. Expired, @@ -82,7 +81,7 @@ pub fn verify_and_decode(token: &str) -> Result { Err(err) => Err(match err.into_kind() { ErrorKind::InvalidSignature => Error::InvalidSignature, ErrorKind::ExpiredSignature => Error::Expired, - kind => Error::InvalidToken(kind), + _ => Error::InvalidToken, }), } } @@ -115,7 +114,7 @@ mod tests { fn test_encode() { test_env(); - assert_eq!(encode(&"test".to_string()).is_empty(), false); + assert!(!encode("test").is_empty()); } #[test] @@ -128,7 +127,7 @@ mod tests { assert!(result.is_err()); assert_eq!( result.err().unwrap(), - Error::InvalidToken(ErrorKind::InvalidToken) + Error::InvalidToken ); }