Skip to content

Commit c6ef984

Browse files
committed
Lint files
1 parent 60f1b4b commit c6ef984

File tree

9 files changed

+32
-38
lines changed

9 files changed

+32
-38
lines changed

app/src/cache.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ impl AppCache {
2424
}
2525
}
2626
}
27+
28+
impl Default for AppCache {
29+
fn default() -> Self {
30+
Self::new()
31+
}
32+
}

app/src/models/bm/player.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use std::ops::Deref;
2-
3-
use chrono::DateTime;
41
use poem::Result;
5-
use poem_openapi::{payload::Json, types::ToJSON, Object, OpenApi};
6-
use reqwest::{Client, ClientBuilder};
2+
use poem_openapi::Object;
3+
use reqwest::ClientBuilder;
74
use serde::{Deserialize, Serialize};
85
use tracing::{info, warn};
96

app/src/models/bm/recent.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use chrono::DateTime;
22
use poem::Result;
3-
use poem_openapi::{Object, OpenApi};
4-
use reqwest::{Client, ClientBuilder};
3+
use poem_openapi::Object;
4+
use reqwest::ClientBuilder;
55
use serde::{Deserialize, Serialize};
66
use tracing::{info, warn};
77

@@ -56,7 +56,7 @@ impl BattleMetricsRecentServer {
5656
.relationships
5757
.as_ref()
5858
.and_then(|r| r.game.as_ref())
59-
.map_or(false, |d| d.data._type == "game" && d.data.id == "rust");
59+
.is_some_and(|d| d.data._type == "game" && d.data.id == "rust");
6060

6161
if !is_rust {
6262
return None;
@@ -84,15 +84,11 @@ impl BattleMetricsRecentServer {
8484
tags: value.attributes.as_ref().and_then(|a| {
8585
a.extra.get("details").and_then(|d| {
8686
d.get("tags").and_then(|v| {
87-
if let Some(arr) = v.as_array() {
88-
Some(
89-
arr.iter()
90-
.filter_map(|item| item.as_str().map(|s| s.to_string()))
91-
.collect(),
92-
)
93-
} else {
94-
None
95-
}
87+
v.as_array().map(|arr|
88+
arr.iter()
89+
.filter_map(|item| item.as_str().map(|s| s.to_string()))
90+
.collect()
91+
)
9692
})
9793
})
9894
}),

app/src/server/auth/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ impl AuthApi {
5252
})?;
5353

5454
// Check if it starts with "Bearer " and extract the token
55-
let token = if auth_header.starts_with("Bearer ") {
56-
auth_header[7..].to_string()
55+
let token = if let Some(token_str) = auth_header.strip_prefix("Bearer ") {
56+
token_str.to_string()
5757
} else {
5858
return Err(poem::Error::from_string(
5959
"Invalid Authorization header format. Expected 'Bearer TOKEN'",

app/src/server/auth/mw.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use poem::{web::Data, Error, FromRequest, Request, RequestBody, Result};
1+
use poem::{web::Data, FromRequest, Request, RequestBody, Result};
22
use poem_openapi::{
33
registry::{MetaSecurityScheme, Registry},
44
ApiExtractor, ApiExtractorType, ExtractParamOptions,
55
};
6-
use reqwest::StatusCode;
76
use serde::{Deserialize, Serialize};
87

98
use crate::{models::user::User, state::AppState};
@@ -94,7 +93,6 @@ impl<'a> ApiExtractor<'a> for AuthUser {
9493
vec!["AuthToken"]
9594
}
9695
}
97-
9896
impl AuthUser {
9997
fn state(&self) -> &AppState {
10098
match self {
@@ -103,3 +101,4 @@ impl AuthUser {
103101
}
104102
}
105103
}
104+

app/src/server/auth/oauth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::models::user::User;
22
use crate::server::ApiTags;
33
use crate::state::{AppState, SteamOAuthConfig};
44
use async_std::task;
5-
use poem::{web::Query, EndpointExt, Result};
5+
use poem::{web::Query, Result};
66
use poem_openapi::payload::Response;
77
use poem_openapi::{payload::Html, payload::PlainText, OpenApi};
88
use reqwest::{Client, StatusCode};

app/src/server/bm/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
use crate::{
22
models::bm::{
3-
player::{get_quick_match_players, get_quick_match_players_cached},
4-
recent::{get_recent_server_by_player_id, get_recent_servers_cached, BattleMetricsRecentServers},
3+
player::get_quick_match_players_cached,
4+
recent::{get_recent_servers_cached, BattleMetricsRecentServers},
55
},
66
state::AppState,
77
};
8-
use chrono::DateTime;
98
use poem::{
10-
http::Error,
11-
web::{Data, Query},
12-
EndpointExt, Result,
9+
web::Data,
10+
Result,
1311
};
14-
use poem_openapi::{payload::Json, Object, OpenApi};
15-
use reqwest::{Client, ClientBuilder};
16-
use serde::{Deserialize, Serialize};
17-
use tracing::{info, warn};
12+
use poem_openapi::{payload::Json, OpenApi};
13+
use tracing::info;
1814

1915
use super::auth::mw::AuthUser;
2016

app/src/server/maps/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl MapsApi {
9696
#[oai(path = "/maps/search", method = "get", tag = "ApiTags::Maps")]
9797
async fn search(
9898
&self,
99-
state: Data<&AppState>,
99+
_state: Data<&AppState>,
100100
search: Query<String>,
101101
) -> Result<Json<SearchResponse>> {
102102
let url = format!(
@@ -125,7 +125,7 @@ impl MapsApi {
125125
#[oai(path = "/maps/get", method = "get", tag = "ApiTags::Maps")]
126126
async fn get(
127127
&self,
128-
state: Data<&AppState>,
128+
_state: Data<&AppState>,
129129
map_id: Query<String>,
130130
) -> Result<Json<MapResponse>> {
131131
let url = format!("https://api.rustmaps.com/internal/v1/maps/{}", map_id.0);

app/src/server/party/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl PartyApi {
7878
#[oai(path = "/party/create", method = "post", tag = "ApiTags::Party")]
7979
async fn create(
8080
&self,
81-
state: Data<&AppState>,
81+
_state: Data<&AppState>,
8282
body: Json<PartyCreateRequest>,
8383
) -> Result<Json<PartyCreateResponse>> {
8484
tracing::info!("{:?}", body);
@@ -105,9 +105,9 @@ impl PartyApi {
105105
#[oai(path = "/party/:party_id/get", method = "get", tag = "ApiTags::Party")]
106106
async fn get(
107107
&self,
108-
state: Data<&AppState>,
108+
_state: Data<&AppState>,
109109
party_id: Path<String>,
110-
cursor: Query<String>,
110+
_cursor: Query<String>,
111111
) -> Result<Json<PartyGetResponse>> {
112112
tracing::info!("{:?}", party_id.0);
113113

0 commit comments

Comments
 (0)