Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dankmeme01 committed Dec 1, 2024
1 parent 8dcfc39 commit 28b78bf
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
9 changes: 4 additions & 5 deletions server/central/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ use std::{
time::Duration,
};

use async_watcher::{notify::RecursiveMode, AsyncDebouncer};
use async_watcher::{AsyncDebouncer, notify::RecursiveMode};
use config::ServerConfig;
use db::GlobedDb;
use game_pinger::GameServerPinger;
use globed_shared::{
get_log_level,
logger::{error, info, log, warn, Logger},
LogLevelFilter,
LogLevelFilter, get_log_level,
logger::{Logger, error, info, log, warn},
};
use rocket::catchers;
use rocket_db_pools::Database;
Expand Down Expand Up @@ -62,7 +61,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// create Rocket.toml if it doesn't exist
let rocket_toml = std::env::var("ROCKET_CONFIG").map_or_else(|_| std::env::current_dir().unwrap().join("Rocket.toml"), PathBuf::from);

if !rocket_toml.file_name().is_some_and(|x| x == "Rocket.toml") || !rocket_toml.parent().is_some_and(Path::exists) {
if rocket_toml.file_name().is_none_or(|x| x != "Rocket.toml") || !rocket_toml.parent().is_some_and(Path::exists) {
error!("invalid value for ROCKET_CONFIG");
warn!("hint: the filename must be 'Rocket.toml' and the parent folder must exist on the disk");
abort_misconfig();
Expand Down
2 changes: 1 addition & 1 deletion server/central/src/web/routes/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ pub async fn challenge_verify(
// verify trust token
let trust_token = if let Ok(sm_key) = std::env::var("GLOBED_GS_SECURE_MODE_KEY") {
if let Some(trust_token) = &post_data.0.trust_token {
let decrypted = String::from_utf8(decrypt_trust_token(&trust_token, &sm_key)?)?;
let decrypted = String::from_utf8(decrypt_trust_token(trust_token, &sm_key)?)?;
if let Some((s_value, token_rest)) = decrypted.split_once('|') {
if s_value != challenge.value {
unauthorized!("security check failed: trust token value mismatch");
Expand Down
12 changes: 4 additions & 8 deletions server/esp/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ use std::{

// this is bizarre
const fn constmax(a: usize, b: usize) -> usize {
if a >= b {
a
} else {
b
}
if a >= b { a } else { b }
}

macro_rules! impl_primitive {
Expand Down Expand Up @@ -153,7 +149,7 @@ where

/* Cow<'a, T> */

impl<'a, T: ?Sized + ToOwned> Encodable for Cow<'a, T>
impl<T: ?Sized + ToOwned> Encodable for Cow<'_, T>
where
<T as ToOwned>::Owned: Encodable,
T: Encodable,
Expand All @@ -175,7 +171,7 @@ where
}
}

impl<'a, T: ?Sized + ToOwned> Decodable for Cow<'a, T>
impl<T: ?Sized + ToOwned> Decodable for Cow<'_, T>
where
<T as ToOwned>::Owned: Decodable,
T: Decodable,
Expand All @@ -189,7 +185,7 @@ where
}
}

impl<'a, T: ?Sized + ToOwned> DynamicSize for Cow<'a, T>
impl<T: ?Sized + ToOwned> DynamicSize for Cow<'_, T>
where
<T as ToOwned>::Owned: DynamicSize,
T: DynamicSize,
Expand Down
4 changes: 2 additions & 2 deletions server/esp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ impl ByteBufferExtWrite for ByteBuffer {
impl_extwrite!(encode);
}

impl<'a> ByteBufferExtWrite for FastByteBuffer<'a> {
impl ByteBufferExtWrite for FastByteBuffer<'_> {
impl_extwrite!(encode_fast);
}

impl ByteBufferExtRead for ByteBuffer {
impl_extread!(decode);
}

impl<'a> ByteBufferExtRead for ByteReader<'a> {
impl ByteBufferExtRead for ByteReader<'_> {
impl_extread!(decode_from_reader);
}

Expand Down
9 changes: 5 additions & 4 deletions server/game/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use std::{
};

use esp::{
size_of_types, ByteBuffer, ByteBufferExt, ByteBufferExtRead, ByteBufferExtWrite, ByteReader, Decodable, DecodeError, DynamicSize, Encodable,
FastVec, StaticSize,
ByteBuffer, ByteBufferExt, ByteBufferExtRead, ByteBufferExtWrite, ByteReader, Decodable, DecodeError, DynamicSize, Encodable, FastVec,
StaticSize, size_of_types,
};
use globed_derive::{DynamicSize, Encodable};
use globed_shared::{
GameServerBootData, MAX_SUPPORTED_PROTOCOL, SERVER_MAGIC, SERVER_MAGIC_LEN, ServerUserEntry, SyncMutex, TokenIssuer, UserLoginResponse,
data::*,
reqwest::{self, Response, StatusCode},
GameServerBootData, ServerUserEntry, SyncMutex, TokenIssuer, UserLoginResponse, MAX_SUPPORTED_PROTOCOL, SERVER_MAGIC, SERVER_MAGIC_LEN,
};

use crate::webhook::{self, *};
Expand Down Expand Up @@ -160,7 +160,7 @@ impl CentralBridge {
// verify that the magic bytes match
let valid_magic = reader
.read_value_array::<u8, SERVER_MAGIC_LEN>()
.map_or(false, |magic| magic.iter().eq(SERVER_MAGIC.iter()));
.is_ok_and(|magic| magic.iter().eq(SERVER_MAGIC.iter()));

if !valid_magic {
let txt = String::from_utf8(reader.as_bytes().to_vec()).unwrap_or_else(|_| "<invalid UTF-8 string>".to_owned());
Expand Down Expand Up @@ -377,6 +377,7 @@ impl CentralBridge {
Ok(())
}

#[allow(clippy::too_many_arguments)]
pub async fn send_webhook_message_for_action(
&self,
action: &AdminUserAction,
Expand Down
6 changes: 3 additions & 3 deletions server/game/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ pub use esp::*;
pub use globed_derive::*;
pub use globed_shared::MAX_NAME_SIZE;

pub use v_current::VERSION as CURRENT_PROTOCOL;
pub use v_current::packets;
pub use v_current::types;
pub use v_current::VERSION as CURRENT_PROTOCOL;

pub use packets::*;
pub use types::*;
Expand Down Expand Up @@ -39,7 +39,7 @@ impl ByteBufferExtRead2 for ByteBuffer {
}
}

impl<'a> ByteBufferExtRead2 for ByteReader<'a> {
impl ByteBufferExtRead2 for ByteReader<'_> {
#[inline]
fn read_packet_header(&mut self) -> DecodeResult<PacketHeader> {
self.read_value()
Expand Down Expand Up @@ -73,7 +73,7 @@ impl ByteBufferExtWrite2 for ByteBuffer {
}
}

impl<'a> ByteBufferExtWrite2 for FastByteBuffer<'a> {
impl ByteBufferExtWrite2 for FastByteBuffer<'_> {
#[inline]
fn write_packet_header<T: PacketMetadata>(&mut self) {
self.write_value(&PacketHeader::from_packet::<T>());
Expand Down

0 comments on commit 28b78bf

Please sign in to comment.