diff --git a/example/proxy/src/main.rs b/example/proxy/src/main.rs
index 2805e53..7763f0c 100644
--- a/example/proxy/src/main.rs
+++ b/example/proxy/src/main.rs
@@ -32,7 +32,7 @@ fn create_json_response(body: &'static str, status: StatusCode) -> Response
) -> Result, Infallible
};
*out_response.body_mut() = Body::from((&bytes[..]).to_vec());
}
- return Ok(out_response);
+ Ok(out_response)
}
/// Gets the region, method_id, and Riot API path based on the given http method and path.
@@ -111,7 +111,7 @@ fn parse_path<'a>(http_method: &Method, req_path: &'a str) -> Option<( Route, &'
// Find method_id for given path.
let method_id = find_matching_method_id(http_method, req_path)?;
- return Some(( route, method_id, req_path ))
+ Some(( route, method_id, req_path ))
}
/// Finds the method_id given the request path.
diff --git a/riven/src/consts/ranks.rs b/riven/src/consts/ranks.rs
index d8006f4..4489010 100644
--- a/riven/src/consts/ranks.rs
+++ b/riven/src/consts/ranks.rs
@@ -59,7 +59,7 @@ pub fn non_apex_iter() -> Iter {
tier_iter.next();
}
Iter {
- tier_iter: tier_iter,
+ tier_iter,
div_iter: Division::iter(),
}
}
diff --git a/riven/src/consts/route.rs b/riven/src/consts/route.rs
index 1b33e7d..554e671 100644
--- a/riven/src/consts/route.rs
+++ b/riven/src/consts/route.rs
@@ -192,11 +192,11 @@ impl num_enum::TryFromPrimitive for Route {
fn try_from_primitive(number: Self::Primitive) -> Result> {
RegionalRoute::try_from_primitive(number)
- .map(|r| Route::Regional(r))
+ .map(Route::Regional)
.or_else(|_| PlatformRoute::try_from_primitive(number)
- .map(|r| Route::Platform(r)))
+ .map(Route::Platform))
.or_else(|_| ValPlatformRoute::try_from_primitive(number)
- .map(|r| Route::ValPlatform(r)))
+ .map(Route::ValPlatform))
.map_err(|_| num_enum::TryFromPrimitiveError { number })
}
}
@@ -222,11 +222,11 @@ impl std::str::FromStr for Route {
type Err = strum::ParseError;
fn from_str(s: &str) -> Result {
RegionalRoute::from_str(s)
- .map(|r| Self::Regional(r))
+ .map(Self::Regional)
.or_else(|_| PlatformRoute::from_str(s)
- .map(|r| Self::Platform(r)))
+ .map(Self::Platform))
.or_else(|_| ValPlatformRoute::from_str(s)
- .map(|r| Self::ValPlatform(r)))
+ .map(Self::ValPlatform))
.map_err(|_| strum::ParseError::VariantNotFound)
}
}
@@ -236,11 +236,11 @@ impl Route {
use strum::IntoEnumIterator;
let regional = RegionalRoute::iter()
- .map(|r| Self::Regional(r));
+ .map(Self::Regional);
let platform = PlatformRoute::iter()
- .map(|r| Self::Platform(r));
+ .map(Self::Platform);
let val_platform = ValPlatformRoute::iter()
- .map(|r| Self::ValPlatform(r));
+ .map(Self::ValPlatform);
regional
.chain(platform)
diff --git a/riven/src/endpoints.rs b/riven/src/endpoints.rs
index af514f8..c4bb3f8 100644
--- a/riven/src/endpoints.rs
+++ b/riven/src/endpoints.rs
@@ -10,6 +10,7 @@
// Version 309704e3979855858e36430b178e507e48702059
//! Automatically generated endpoint handles.
+#![allow(clippy::let_and_return, clippy::too_many_arguments)]
use crate::models::*;
diff --git a/riven/src/error.rs b/riven/src/error.rs
index 663dcda..8159ae3 100644
--- a/riven/src/error.rs
+++ b/riven/src/error.rs
@@ -20,10 +20,10 @@ pub struct RiotApiError {
impl RiotApiError {
pub(crate) fn new(reqwest_error: Error, retries: u8, response: Option, status_code: Option) -> Self {
Self {
- reqwest_error: reqwest_error,
- retries: retries,
- response: response,
- status_code: status_code,
+ reqwest_error,
+ retries,
+ response,
+ status_code,
}
}
/// The reqwest::Error for the final failed request.
diff --git a/riven/src/meta.rs b/riven/src/meta.rs
index b28a85f..f9219c4 100644
--- a/riven/src/meta.rs
+++ b/riven/src/meta.rs
@@ -13,7 +13,7 @@
//!
//! Note: this modules is automatically generated.
-pub static ALL_ENDPOINTS: [(reqwest::Method, &'static str, &'static str); 70] = [
+pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); 70] = [
(reqwest::Method::GET, "/riot/account/v1/accounts/by-puuid/{puuid}", "account-v1.getByPuuid"),
(reqwest::Method::GET, "/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}", "account-v1.getByRiotId"),
(reqwest::Method::GET, "/riot/account/v1/accounts/me", "account-v1.getByAccessToken"),
diff --git a/riven/src/req/rate_limit.rs b/riven/src/req/rate_limit.rs
index e692bc1..b0a60af 100644
--- a/riven/src/req/rate_limit.rs
+++ b/riven/src/req/rate_limit.rs
@@ -2,7 +2,7 @@ use std::cmp;
use std::time::{ Duration, Instant };
#[cfg(not(feature="tracing"))]
-use log;
+use log as log;
#[cfg(feature="tracing")]
use tracing as log;
@@ -45,7 +45,7 @@ impl RateLimit {
let initial_bucket = VectorTokenBucket::new(
Duration::from_secs(1), 1, Duration::new(0, 0), 1.0, 1.0);
RateLimit {
- rate_limit_type: rate_limit_type,
+ rate_limit_type,
// Rate limit before getting from response: 1/s.
buckets: RwLock::new(vec![initial_bucket]),
retry_after: RwLock::new(None),
@@ -154,7 +154,7 @@ impl RateLimit {
.expect("Failed to parse retry-after header as f32.");
// Add 0.5 seconds to account for rounding, cases when response is zero.
let delay = Duration::from_secs_f32(0.5 + retry_after_secs);
- return Some(Instant::now() + delay);
+ Some(Instant::now() + delay)
}() {
*self.retry_after.write() = Some(retry_after);
}
@@ -188,11 +188,11 @@ impl RateLimit {
}
}
-fn buckets_require_updating(limit_header: &str, buckets: &Vec) -> bool {
- if buckets.len() != limit_header.split(",").count() {
+fn buckets_require_updating(limit_header: &str, buckets: &[VectorTokenBucket]) -> bool {
+ if buckets.len() != limit_header.split(',').count() {
return true;
}
- for (limit_header_entry, bucket) in limit_header.split(",").zip(&*buckets) {
+ for (limit_header_entry, bucket) in limit_header.split(',').zip(buckets) {
// limit_header_entry "100:60" means 100 req per 60 sec.
let bucket_entry = format!("{}:{}", bucket.get_total_limit(), bucket.get_bucket_duration().as_secs());
if limit_header_entry != bucket_entry {
@@ -205,11 +205,11 @@ fn buckets_require_updating(limit_header: &str, buckets: &Vec
fn buckets_from_header(config: &RiotApiConfig, limit_header: &str, count_header: &str, rate_limit_type: RateLimitType) -> Vec {
// Limits: "20000:10,1200000:600"
// Counts: "7:10,58:600"
- let size = limit_header.split(",").count();
- debug_assert!(size == count_header.split(",").count());
+ let size = limit_header.split(',').count();
+ debug_assert!(size == count_header.split(',').count());
let mut out = Vec::with_capacity(size);
- for (limit_entry, count_entry) in limit_header.split(",").zip(count_header.split(",")) {
+ for (limit_entry, count_entry) in limit_header.split(',').zip(count_header.split(',')) {
let (limit, limit_secs) = scan_fmt!(limit_entry, "{d}:{d}", usize, u64)
.unwrap_or_else(|_| panic!("Failed to parse limit entry \"{}\".", limit_entry));
let (count, count_secs) = scan_fmt!(count_entry, "{d}:{d}", usize, u64)
diff --git a/riven/src/req/regional_requester.rs b/riven/src/req/regional_requester.rs
index 63eb2c1..8bb2afe 100644
--- a/riven/src/req/regional_requester.rs
+++ b/riven/src/req/regional_requester.rs
@@ -2,7 +2,7 @@ use std::future::Future;
use std::sync::Arc;
#[cfg(not(feature="tracing"))]
-use log;
+use log as log;
#[cfg(feature="tracing")]
use tracing as log;
#[cfg(feature = "tracing")]
@@ -69,8 +69,8 @@ impl RegionalRequester {
.map_err(|e| RiotApiError::new(e, retries, None, None))?;
// Maybe update rate limits (based on response headers).
- self.app_rate_limit.on_response(&config, &response);
- method_rate_limit.on_response(&config, &response);
+ self.app_rate_limit.on_response(config, &response);
+ method_rate_limit.on_response(config, &response);
let status = response.status();
// Handle normal success / failure cases.
@@ -79,9 +79,9 @@ impl RegionalRequester {
if status.is_success() || status_none {
log::trace!("Response {} (retried {} times), success, returning result.", status, retries);
break Ok(ResponseInfo {
- response: response,
- retries: retries,
- status_none: status_none,
+ response,
+ retries,
+ status_none,
});
}
let err = response.error_for_status_ref().err().unwrap_or_else(
diff --git a/riven/src/req/token_bucket.rs b/riven/src/req/token_bucket.rs
index 953c290..4d0302e 100644
--- a/riven/src/req/token_bucket.rs
+++ b/riven/src/req/token_bucket.rs
@@ -108,7 +108,7 @@ impl VectorTokenBucket {
while timestamps.back().map_or(false, |ts| *ts < cutoff) {
timestamps.pop_back();
}
- return timestamps;
+ timestamps
}
}
@@ -159,7 +159,7 @@ impl TokenBucket for VectorTokenBucket {
}
}
- return true;
+ true
}
fn get_bucket_duration(&self) -> Duration {
diff --git a/riven/src/riot_api.rs b/riven/src/riot_api.rs
index 4962d39..7dff9d8 100644
--- a/riven/src/riot_api.rs
+++ b/riven/src/riot_api.rs
@@ -2,7 +2,7 @@ use std::future::Future;
use std::sync::Arc;
#[cfg(not(feature="tracing"))]
-use log;
+use log as log;
#[cfg(feature="tracing")]
use tracing as log;
@@ -62,7 +62,7 @@ impl RiotApi {
let client_builder = config.client_builder.take()
.expect("CLIENT_BUILDER IN CONFIG SHOULD NOT BE NONE.");
Self {
- config: config,
+ config,
client: client_builder.build().expect("Failed to create client from builder."),
regional_requesters: InsertOnlyCHashMap::new(),
}
diff --git a/riven/srcgen/endpoints.rs.dt b/riven/srcgen/endpoints.rs.dt
index b929eaf..ea76b33 100644
--- a/riven/srcgen/endpoints.rs.dt
+++ b/riven/srcgen/endpoints.rs.dt
@@ -7,6 +7,7 @@
// Version {{= spec.info.version }}
//! Automatically generated endpoint handles.
+#![allow(clippy::let_and_return, clippy::too_many_arguments)]
use crate::models::*;
diff --git a/riven/srcgen/meta.rs.dt b/riven/srcgen/meta.rs.dt
index a8139ae..256ade2 100644
--- a/riven/srcgen/meta.rs.dt
+++ b/riven/srcgen/meta.rs.dt
@@ -18,7 +18,7 @@
//!
//! Note: this modules is automatically generated.
-pub static ALL_ENDPOINTS: [(reqwest::Method, &'static str, &'static str); {{= operations.length }}] = [
+pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); {{= operations.length }}] = [
{{
for (const { route, method, operation } of operations) {
}}
diff --git a/riven/tests/tests_americas.rs b/riven/tests/tests_americas.rs
index aaa5a2c..9b3315e 100644
--- a/riven/tests/tests_americas.rs
+++ b/riven/tests/tests_americas.rs
@@ -12,7 +12,7 @@ use riven::models::tournament_stub_v4::*;
const ROUTE: RegionalRoute = RegionalRoute::AMERICAS;
-static MATCHES: [&'static str; 4] = [ "NA1_3923487226", "NA1_4049206905", "NA1_4052515784", "NA1_4062578191" ];
+static MATCHES: [&str; 4] = [ "NA1_3923487226", "NA1_4049206905", "NA1_4052515784", "NA1_4062578191" ];
async_tests!{
my_runner {
diff --git a/riven/tests/tests_asia.rs b/riven/tests/tests_asia.rs
index 2a9058a..04be90b 100644
--- a/riven/tests/tests_asia.rs
+++ b/riven/tests/tests_asia.rs
@@ -11,7 +11,7 @@ use riven::consts::*;
const ROUTE: RegionalRoute = RegionalRoute::ASIA;
-static MATCHES: [&'static str; 1] = [ "KR_5495121707" ];
+static MATCHES: [&str; 1] = [ "KR_5495121707" ];
async_tests!{
my_runner {
diff --git a/riven/tests/tests_euw.rs b/riven/tests/tests_euw.rs
index 6ab3a5a..2ac0745 100644
--- a/riven/tests/tests_euw.rs
+++ b/riven/tests/tests_euw.rs
@@ -16,16 +16,16 @@ async_tests!{
// Champion Mastery tests.
championmastery_getscore_ma5tery: async {
let sum = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "ma5tery");
- let sum = sum.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
+ let sum = sum.await.map_err(|e| e.to_string())?.ok_or_else(|| "Failed to get summoner".to_owned())?;
let p = RIOT_API.champion_mastery_v4().get_champion_mastery_score(ROUTE, &*sum.id);
let s = p.await.map_err(|e| e.to_string())?;
- rassert!(969 <= s && s <= 1000, "Unexpected ma5tery score: {}.", s);
+ rassert!((969..=1000).contains(&s), "Unexpected ma5tery score: {}.", s);
Ok(())
},
championmastery_getall_ma5tery: async {
let sum = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "ma5tery");
- let sum = sum.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
+ let sum = sum.await.map_err(|e| e.to_string())?.ok_or_else(|| "Failed to get summoner".to_owned())?;
let p = RIOT_API.champion_mastery_v4().get_all_champion_masteries(ROUTE, &*sum.id);
let s = p.await.map_err(|e| e.to_string())?;
@@ -36,11 +36,11 @@ async_tests!{
let featured_p = RIOT_API.spectator_v4().get_featured_games(ROUTE);
let featured = featured_p.await.map_err(|e| e.to_string())?;
- rassert!(featured.game_list.len() > 0);
+ rassert!(!featured.game_list.is_empty());
let summoner_name = &featured.game_list[0].participants[0].summoner_name;
let summoner_p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, summoner_name);
- let summoner = summoner_p.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
+ let summoner = summoner_p.await.map_err(|e| e.to_string())?.ok_or_else(|| "Failed to get summoner".to_owned())?;
let livegame_p = RIOT_API.spectator_v4().get_current_game_info_by_summoner(ROUTE, &summoner.id);
let livegame_o = livegame_p.await.map_err(|e| e.to_string())?;
diff --git a/riven/tests/tests_jp.rs b/riven/tests/tests_jp.rs
index 93021c0..7281ee0 100644
--- a/riven/tests/tests_jp.rs
+++ b/riven/tests/tests_jp.rs
@@ -16,7 +16,7 @@ async_tests!{
// Summoner tests.
summoner_get_kanjikana: async {
let p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "私の 頭が かたい");
- let s = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get myheadhard".to_owned())?;
+ let s = p.await.map_err(|e| e.to_string())?.ok_or_else(|| "Failed to get myheadhard".to_owned())?;
rassert_eq!("私の頭がかたい", s.name);
Ok(())
},
@@ -54,10 +54,10 @@ async_tests!{
// // https://github.com/MingweiSamuel/Riven/issues/25
// tft_league_getleagueentriesforsummoner: async {
// let sp = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "Caihonbbt");
- // let sr = sp.await.map_err(|e| e.to_string())?.ok_or("Failed to get \"Caihonbbt\"".to_owned())?;
+ // let sr = sp.await.map_err(|e| e.to_string())?.ok_or_else(|| "Failed to get \"Caihonbbt\"".to_owned())?;
// let lp = RIOT_API.tft_league_v1().get_league_entries_for_summoner(ROUTE, &sr.id);
// let lr = lp.await.map_err(|e| e.to_string())?;
- // rassert!(0 < lr.len());
+ // rassert!(!lr.is_empty());
// Ok(())
// },
// tft-league-v1.getTopRatedLadder
@@ -65,7 +65,7 @@ async_tests!{
tft_league_gettopratedladder: async {
let lp = RIOT_API.tft_league_v1().get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
let lr = lp.await.map_err(|e| e.to_string())?;
- rassert!(0 < lr.len());
+ rassert!(!lr.is_empty());
Ok(())
},
}
diff --git a/riven/tests/tests_na.rs b/riven/tests/tests_na.rs
index 4bb2783..1ad35b8 100644
--- a/riven/tests/tests_na.rs
+++ b/riven/tests/tests_na.rs
@@ -25,8 +25,8 @@ async_tests!{
summoner_double: async {
let l1p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "lug nuts k");
let l2p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "lugnuts k");
- let l1 = l1p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l1".to_owned())?;
- let l2 = l2p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l2".to_owned())?;
+ let l1 = l1p.await.map_err(|e| e.to_string())?.ok_or_else(|| "Failed to get l1".to_owned())?;
+ let l2 = l2p.await.map_err(|e| e.to_string())?.ok_or_else(|| "Failed to get l2".to_owned())?;
validate_summoners(l1, l2)?;
Ok(())
},
diff --git a/riven/tests/testutils.rs b/riven/tests/testutils.rs
index 92e0ad0..00df739 100644
--- a/riven/tests/testutils.rs
+++ b/riven/tests/testutils.rs
@@ -14,9 +14,9 @@ lazy_static! {
}
pub mod ids {
- pub const SUMMONER_ID_LUGNUTSK: &'static str = "SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw";
- pub const SUMMONER_ID_MA5TERY: &'static str = "IbC4uyFEEW3ZkZw6FZF4bViw3P1EynclAcI6-p-vCpI99Ec";
- pub const SUMMONER_ID_C9SNEAKY: &'static str = "ghHSdADqgxKwcRl_vWndx6wKiyZx0xKQv-LOhOcU5LU";
- pub const ACCOUNT_ID_C9SNEAKY: &'static str = "ML_CcLT94UUHp1iDvXOXCidfmzzPrk_Jbub1f_INhw";
- pub const ACCOUNT_ID_LUGNUTSK: &'static str = "iheZF2uJ50S84Hfq6Ob8GNlJAUmBmac-EsEEWBJjD01q1jQ";
+ pub const SUMMONER_ID_LUGNUTSK: &str = "SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw";
+ pub const SUMMONER_ID_MA5TERY: &str = "IbC4uyFEEW3ZkZw6FZF4bViw3P1EynclAcI6-p-vCpI99Ec";
+ pub const SUMMONER_ID_C9SNEAKY: &str = "ghHSdADqgxKwcRl_vWndx6wKiyZx0xKQv-LOhOcU5LU";
+ pub const ACCOUNT_ID_C9SNEAKY: &str = "ML_CcLT94UUHp1iDvXOXCidfmzzPrk_Jbub1f_INhw";
+ pub const ACCOUNT_ID_LUGNUTSK: &str = "iheZF2uJ50S84Hfq6Ob8GNlJAUmBmac-EsEEWBJjD01q1jQ";
}