Skip to content

Commit d1e2443

Browse files
committed
chore: apply latest clippy lints and formatting
1 parent 8b5d0cb commit d1e2443

48 files changed

Lines changed: 163 additions & 172 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/database/entities/game_report.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
},
77
};
88
use futures_util::future::BoxFuture;
9-
use sea_orm::{entity::prelude::*, ActiveValue::Set, FromJsonQueryResult};
9+
use sea_orm::{ActiveValue::Set, FromJsonQueryResult, entity::prelude::*};
1010
use serde::{Deserialize, Serialize};
1111
use std::collections::HashMap;
1212

src/database/entities/leaderboard_data.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
33
use crate::database::DbResult;
44
use crate::utils::types::PlayerID;
5-
use sea_orm::sea_query::OnConflict;
65
use sea_orm::ActiveValue::NotSet;
7-
use sea_orm::{prelude::*, FromQueryResult, InsertResult, QueryOrder, QuerySelect};
6+
use sea_orm::sea_query::OnConflict;
87
use sea_orm::{ActiveValue::Set, DatabaseConnection, EntityTrait};
8+
use sea_orm::{FromQueryResult, InsertResult, QueryOrder, QuerySelect, prelude::*};
99
use serde::{Deserialize, Serialize};
1010
use std::future::Future;
1111

@@ -175,7 +175,7 @@ impl Model {
175175
// The number of ranks to start at before the centered rank
176176
let before = (count / 2)
177177
// Add 1 when the count is even
178-
.saturating_add((count % 2 == 0) as u32);
178+
.saturating_add(count.is_multiple_of(2) as u32);
179179

180180
// Determine the starting rank saturating zero bounds
181181
let start = value.rank.saturating_sub(before);

src/database/entities/player_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::{database::DbResult, utils::types::PlayerID};
22
use sea_orm::{
3-
entity::prelude::*,
4-
sea_query::OnConflict,
53
ActiveValue::{NotSet, Set},
64
DeleteResult, InsertResult,
5+
entity::prelude::*,
6+
sea_query::OnConflict,
77
};
88
use serde::Serialize;
99
use std::future::Future;

src/database/entities/players.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Model {
101101
/// Deletes the provided player
102102
///
103103
/// `db` The database connection
104-
pub fn delete(self, db: &DatabaseConnection) -> BoxFuture<DbResult<DeleteResult>> {
104+
pub fn delete(self, db: &DatabaseConnection) -> BoxFuture<'_, DbResult<DeleteResult>> {
105105
// Delete player itself
106106
self.into_active_model().delete(db)
107107
}

src/database/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use log::{error, info, warn};
22
use migration::{Migrator, MigratorTrait};
33
use sea_orm::Database as SeaDatabase;
44
use std::{
5-
fs::{create_dir_all, File},
5+
fs::{File, create_dir_all},
66
path::Path,
77
};
88

@@ -47,10 +47,10 @@ async fn connect_database() -> DatabaseConnection {
4747
let path = Path::new(&DATABASE_PATH);
4848

4949
// Create path to database file if missing
50-
if let Some(parent) = path.parent() {
51-
if !parent.exists() {
52-
create_dir_all(parent).expect("Unable to create parent directory for sqlite database");
53-
}
50+
if let Some(parent) = path.parent()
51+
&& !parent.exists()
52+
{
53+
create_dir_all(parent).expect("Unable to create parent directory for sqlite database");
5454
}
5555

5656
// Create the database if file is missing

src/database/seed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use chrono::Local;
2-
use rand::{distr::Uniform, Rng};
2+
use rand::{Rng, distr::Uniform};
33
use sea_orm::{
44
ActiveModelTrait,
55
ActiveValue::{NotSet, Set},
@@ -8,8 +8,8 @@ use tokio::{task::JoinSet, try_join};
88

99
use crate::{
1010
database::entities::{
11-
galaxy_at_war::ActiveModel as GawActiveModel, leaderboard_data::LeaderboardType,
12-
players::ActiveModel as PlayerActiveModel, LeaderboardData, PlayerData, PlayerRole,
11+
LeaderboardData, PlayerData, PlayerRole, galaxy_at_war::ActiveModel as GawActiveModel,
12+
leaderboard_data::LeaderboardType, players::ActiveModel as PlayerActiveModel,
1313
},
1414
utils::hashing::hash_password,
1515
};

src/middleware/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{
22
config::Config,
33
database::{
4-
entities::{players::PlayerRole, Player},
54
DbErr,
5+
entities::{Player, players::PlayerRole},
66
},
77
services::sessions::{Sessions, VerifyError},
88
};

src/middleware/cors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use axum::{
22
body::Body,
3-
http::{header, HeaderValue, Method, StatusCode},
3+
http::{HeaderValue, Method, StatusCode, header},
44
middleware::Next,
55
response::Response,
66
};
@@ -44,12 +44,12 @@ pub async fn cors_layer(req: Request<Body>, next: Next) -> Response {
4444
#[cfg(test)]
4545
mod test {
4646
use super::cors_layer;
47-
use axum::{body::Body, middleware::from_fn, routing::get, Router};
47+
use axum::{Router, body::Body, middleware::from_fn, routing::get};
4848
use hyper::{
49+
Method, Request, StatusCode,
4950
header::{
5051
ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN,
5152
},
52-
Method, Request, StatusCode,
5353
};
5454
use tower::ServiceExt;
5555

src/middleware/ip_address.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use axum::{
2-
extract::{rejection::ExtensionRejection, ConnectInfo, FromRequestParts},
2+
Extension,
3+
extract::{ConnectInfo, FromRequestParts, rejection::ExtensionRejection},
34
http::request::Parts,
45
response::{IntoResponse, Response},
5-
Extension,
66
};
7-
use hyper::{header::ToStrError, HeaderMap, StatusCode};
7+
use hyper::{HeaderMap, StatusCode, header::ToStrError};
88
use log::warn;
99
use std::{
1010
net::{AddrParseError, IpAddr, Ipv4Addr, SocketAddr},
@@ -47,7 +47,7 @@ where
4747
Extension::<ConnectInfo<SocketAddr>>::from_request_parts(parts, state)
4848
.await
4949
.map_err(IpAddressError::ConnectInfo)
50-
.and_then(|value| try_socket_address(value.0 .0))
50+
.and_then(|value| try_socket_address(value.0.0))
5151
.map(Self)
5252
}
5353
}
@@ -122,7 +122,7 @@ impl IntoResponse for IpAddressError {
122122
mod test {
123123
use crate::config::Config;
124124

125-
use super::{extract_ip_header, IpAddress, IpAddressError, REAL_IP_HEADER};
125+
use super::{IpAddress, IpAddressError, REAL_IP_HEADER, extract_ip_header};
126126
use axum::{
127127
extract::{ConnectInfo, FromRequestParts},
128128
http::HeaderValue,

src/middleware/upgrade.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use axum::{
22
extract::FromRequestParts,
3-
http::{request::Parts, Method, StatusCode},
3+
http::{Method, StatusCode, request::Parts},
44
response::IntoResponse,
55
};
66
use hyper::upgrade::OnUpgrade;

0 commit comments

Comments
 (0)