From 0d1235b7424568e484461a4813a4c3c61968cb17 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 13 Sep 2024 03:31:20 +0200 Subject: [PATCH] Apply clippy lints --- todored/src/routes/board/axum.rs | 2 +- todored/src/routes/board/limit.rs | 4 ++-- todored/src/routes/board/stream.rs | 2 +- todored/src/routes/board/ws_receive.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/todored/src/routes/board/axum.rs b/todored/src/routes/board/axum.rs index dffe468..7101240 100644 --- a/todored/src/routes/board/axum.rs +++ b/todored/src/routes/board/axum.rs @@ -45,7 +45,7 @@ pub(crate) async fn handler( log::trace!("Connection rate limit is: {count} / 60 s"); if count > 0 { log::trace!("Checking rate limit..."); - let result = super::limit::rate_limit_by_key(&mut handle_redis, &rate_limit_key, 1, count, 60).await; + let result = super::limit::rate_limit_by_key(&mut handle_redis, rate_limit_key, 1, count, 60).await; if result.is_err() { return Err::<(), StatusCode>(StatusCode::BAD_REQUEST).into_response() } diff --git a/todored/src/routes/board/limit.rs b/todored/src/routes/board/limit.rs index 94868cd..7e00479 100644 --- a/todored/src/routes/board/limit.rs +++ b/todored/src/routes/board/limit.rs @@ -12,7 +12,7 @@ pub async fn rate_limit_by_key( ) -> Result { log::trace!("Incrementing rate limit counter for {key:?}..."); let response: usize = redis::cmd("INCRBY") - .arg(&key) + .arg(key) .arg(increment) .query_async::(rconn).await .log_err_to_error("Could not increase rate limit counter") @@ -20,7 +20,7 @@ pub async fn rate_limit_by_key( log::trace!("Refreshing rate limit counter expiration for {key:?}..."); let _ = redis::cmd("EXPIRE") - .arg(&key) + .arg(key) .arg(expiration_s) .query_async::(rconn).await .log_err_to_warn("Could not set expiration for rate limit counter"); diff --git a/todored/src/routes/board/stream.rs b/todored/src/routes/board/stream.rs index 1957d35..5785dec 100644 --- a/todored/src/routes/board/stream.rs +++ b/todored/src/routes/board/stream.rs @@ -4,7 +4,7 @@ use crate::task::{v1, VersionedBoardChange}; pub async fn xread_to_vbc(r: StreamReadReply) -> (Vec, String) { log::trace!("Making sure that the Redis Stream existed..."); - let r = r.keys.get(0); + let r = r.keys.first(); let mut current_id: String = "0".to_string(); diff --git a/todored/src/routes/board/ws_receive.rs b/todored/src/routes/board/ws_receive.rs index 9d7d865..63dfe61 100644 --- a/todored/src/routes/board/ws_receive.rs +++ b/todored/src/routes/board/ws_receive.rs @@ -24,7 +24,7 @@ pub async fn handler( log::trace!("Connection rate limit is: {count} / 60 s"); if count > 0 { log::trace!("Checking rate limit..."); - let result = super::limit::rate_limit_by_key(&mut rconn, &rate_limit_key, 1, count, 60).await; + let result = super::limit::rate_limit_by_key(&mut rconn, rate_limit_key, 1, count, 60).await; if result.is_err() { log::warn!("Hit rate limit, closing connection."); return Err(1008u16);