From 1b84f5a8553a07b06acce73dc30e35b88d5c2cec Mon Sep 17 00:00:00 2001 From: strawberry Date: Thu, 4 Apr 2024 23:21:04 -0400 Subject: [PATCH] resolve wildcard_imports and checked_conversations lints Signed-off-by: strawberry --- Cargo.toml | 2 ++ src/routes.rs | 2 +- src/service/media/mod.rs | 4 ++-- src/service/presence/mod.rs | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 08d35a7a..a6282e58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -527,6 +527,8 @@ explicit_deref_methods = "warn" explicit_iter_loop = "warn" manual_let_else = "warn" trivially_copy_pass_by_ref = "warn" +wildcard_imports = "warn" +checked_conversions = "warn" # some sadness missing_errors_doc = "allow" diff --git a/src/routes.rs b/src/routes.rs index 7f325c85..cb43322f 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -8,7 +8,7 @@ use axum::{ }; use conduit::{ api::{client_server, server_server}, - *, + Error, Result, Ruma, RumaResponse, }; use http::{Method, Uri}; use ruma::api::{client::error::ErrorKind, IncomingRequest}; diff --git a/src/service/media/mod.rs b/src/service/media/mod.rs index 6d728a13..6d3ef196 100644 --- a/src/service/media/mod.rs +++ b/src/service/media/mod.rs @@ -394,12 +394,12 @@ impl Service { u64::from(original_width) * u64::from(height) / u64::from(original_height) }; if use_width { - if intermediate <= u64::from(u32::MAX) { + if u32::try_from(intermediate).is_ok() { (width, intermediate as u32) } else { ((u64::from(width) * u64::from(u32::MAX) / intermediate) as u32, u32::MAX) } - } else if intermediate <= u64::from(u32::MAX) { + } else if u32::try_from(intermediate).is_ok() { (intermediate as u32, height) } else { (u32::MAX, (u64::from(height) * u64::from(u32::MAX) / intermediate) as u32) diff --git a/src/service/presence/mod.rs b/src/service/presence/mod.rs index 534894cc..1b8672f7 100644 --- a/src/service/presence/mod.rs +++ b/src/service/presence/mod.rs @@ -110,6 +110,8 @@ impl Service { /// Pings the presence of the given user in the given room, setting the /// specified state. pub fn ping_presence(&self, user_id: &UserId, new_state: &PresenceState) -> Result<()> { + const REFRESH_TIMEOUT: u64 = 60 * 25 * 1000; + let last_presence = self.db.get_presence(user_id)?; let state_changed = match last_presence { None => true, @@ -121,7 +123,6 @@ impl Service { Some((_, ref presence)) => presence.content.last_active_ago.unwrap_or_default().into(), }; - const REFRESH_TIMEOUT: u64 = 60 * 25 * 1000; if !state_changed && last_last_active_ago < REFRESH_TIMEOUT { return Ok(()); }