From 7fc6f718c544ad4051a16db4e562a05f9019fea6 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Thu, 23 May 2024 22:52:57 +0300 Subject: [PATCH] test(lint): fix code style based on linter report --- examples/presence_state.rs | 5 ----- src/core/event_engine/effect_dispatcher.rs | 22 ---------------------- src/core/retry_policy.rs | 4 +--- src/dx/access/mod.rs | 4 ++-- src/dx/presence/mod.rs | 2 +- src/dx/subscribe/event_engine/state.rs | 2 +- src/dx/subscribe/subscription.rs | 2 +- src/dx/subscribe/subscription_manager.rs | 2 +- src/dx/subscribe/subscription_set.rs | 4 ++-- 9 files changed, 9 insertions(+), 38 deletions(-) diff --git a/examples/presence_state.rs b/examples/presence_state.rs index 25b97d4f..4494dbf4 100644 --- a/examples/presence_state.rs +++ b/examples/presence_state.rs @@ -7,11 +7,6 @@ struct State { is_doing: String, flag: bool, } -#[derive(Debug, serde::Serialize)] -struct State2 { - is_doing: String, - business: String, -} #[tokio::main] async fn main() -> Result<(), Box> { diff --git a/src/core/event_engine/effect_dispatcher.rs b/src/core/event_engine/effect_dispatcher.rs index ea219e49..6fa8559a 100644 --- a/src/core/event_engine/effect_dispatcher.rs +++ b/src/core/event_engine/effect_dispatcher.rs @@ -159,7 +159,6 @@ where mod should { use super::*; use crate::core::event_engine::Event; - use std::future::Future; struct TestEvent; @@ -261,27 +260,6 @@ mod should { } } - #[derive(Clone)] - struct TestRuntime {} - - #[async_trait::async_trait] - impl Runtime for TestRuntime { - fn spawn(&self, _future: impl Future + Send + 'static) - where - R: Send + 'static, - { - // Do nothing. - } - - async fn sleep(self, _delay: u64) { - // Do nothing. - } - - async fn sleep_microseconds(self, _delay: u64) { - // Do nothing. - } - } - #[test] fn create_not_managed_effect() { let (_tx, rx) = async_channel::bounded::(5); diff --git a/src/core/retry_policy.rs b/src/core/retry_policy.rs index 37dd0146..58e39c12 100644 --- a/src/core/retry_policy.rs +++ b/src/core/retry_policy.rs @@ -304,9 +304,7 @@ impl RequestRetryConfiguration { /// * `Some(delay_in_microseconds)` - The delay in microseconds. /// * `None` - If `delay_in_seconds` is `None`. fn delay_in_microseconds(delay_in_seconds: Option) -> Option { - let Some(delay_in_seconds) = delay_in_seconds else { - return None; - }; + let delay_in_seconds = delay_in_seconds?; const MICROS_IN_SECOND: u64 = 1_000_000; let delay = delay_in_seconds * MICROS_IN_SECOND; diff --git a/src/dx/access/mod.rs b/src/dx/access/mod.rs index 03bf7f35..b83fad26 100644 --- a/src/dx/access/mod.rs +++ b/src/dx/access/mod.rs @@ -350,7 +350,7 @@ mod it_should { response: None, request_handler: Some(Box::new(|req| { assert!(req.query_parameters.contains_key("timestamp")); - assert!(req.query_parameters.get("timestamp").is_some()); + assert!(req.query_parameters.contains_key("timestamp")); })), }; @@ -368,7 +368,7 @@ mod it_should { response: None, request_handler: Some(Box::new(|req| { assert!(req.query_parameters.contains_key("signature")); - assert!(req.query_parameters.get("signature").is_some()); + assert!(req.query_parameters.contains_key("signature")); assert!(req .query_parameters .get("signature") diff --git a/src/dx/presence/mod.rs b/src/dx/presence/mod.rs index b0baeb76..04980354 100644 --- a/src/dx/presence/mod.rs +++ b/src/dx/presence/mod.rs @@ -840,7 +840,7 @@ mod it_should { response: None, request_handler: Some(Box::new(|req| { assert!(req.query_parameters.contains_key("state")); - assert!(req.query_parameters.get("state").is_some()); + assert!(req.query_parameters.contains_key("state")); let state = req.query_parameters.get("state").unwrap(); assert!(state.contains("channel_a")); diff --git a/src/dx/subscribe/event_engine/state.rs b/src/dx/subscribe/event_engine/state.rs index f5debe80..b8ad7ecf 100644 --- a/src/dx/subscribe/event_engine/state.rs +++ b/src/dx/subscribe/event_engine/state.rs @@ -329,7 +329,7 @@ impl SubscribeState { // Merge stored cursor with service-provided. let mut next_cursor = next_cursor.clone(); if let Some(cursor) = cursor { - next_cursor.timetoken = cursor.timetoken.clone(); + next_cursor.timetoken.clone_from(&cursor.timetoken); } Some(self.transition_to( diff --git a/src/dx/subscribe/subscription.rs b/src/dx/subscribe/subscription.rs index 9bca92ff..66f57c60 100644 --- a/src/dx/subscribe/subscription.rs +++ b/src/dx/subscribe/subscription.rs @@ -537,7 +537,7 @@ where .gt(current_cursor) .then(|| *cursor_slot = Some(catchup_cursor)); } else { - *cursor_slot = cursor.clone(); + cursor_slot.clone_from(&cursor); } } } diff --git a/src/dx/subscribe/subscription_manager.rs b/src/dx/subscribe/subscription_manager.rs index 93cc16aa..e74b278a 100644 --- a/src/dx/subscribe/subscription_manager.rs +++ b/src/dx/subscribe/subscription_manager.rs @@ -346,7 +346,7 @@ where if !event_handlers.is_empty() { if let Some((_, handler)) = event_handlers.iter().next() { if let Some(handler) = handler.upgrade().clone() { - client = handler.client().upgrade().clone(); + client.clone_from(&handler.client().upgrade()); } } } diff --git a/src/dx/subscribe/subscription_set.rs b/src/dx/subscribe/subscription_set.rs index a967aceb..da2242c4 100644 --- a/src/dx/subscribe/subscription_set.rs +++ b/src/dx/subscribe/subscription_set.rs @@ -903,7 +903,7 @@ where .gt(current_cursor) .then(|| *cursor_slot = Some(catchup_cursor)); } else { - *cursor_slot = cursor.clone(); + cursor_slot.clone_from(&cursor); } } } @@ -1174,7 +1174,7 @@ mod it_should { .into_iter() .map(|name| client.channel(name).subscription(None)) .collect::>>(); - let channels_3_subscriptions = vec![ + let channels_3_subscriptions = [ channels_1_subscriptions[0].clone(), channels_2_subscriptions[1].clone(), ];