mirror of https://github.com/MingweiSamuel/Riven
cargo clippy fixes, enable lints in CI
parent
e53d78c807
commit
cb5bd58784
|
@ -90,31 +90,31 @@ jobs:
|
|||
RUSTLOG: riven=trace
|
||||
RGAPI_KEY: ${{ secrets.RGAPI_KEY }}
|
||||
|
||||
# lints:
|
||||
# name: Lints
|
||||
# needs: pre_job
|
||||
# if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Checkout sources
|
||||
# uses: actions/checkout@v2
|
||||
lints:
|
||||
name: Lints
|
||||
needs: pre_job
|
||||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# - name: Install nightly toolchain
|
||||
# uses: actions-rs/toolchain@v1
|
||||
# with:
|
||||
# profile: minimal
|
||||
# toolchain: nightly
|
||||
# override: true
|
||||
# components: rustfmt, clippy
|
||||
- name: Install nightly toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
# - name: Run cargo fmt
|
||||
# uses: actions-rs/cargo@v1
|
||||
# with:
|
||||
# command: fmt
|
||||
# args: --all -- --check
|
||||
- name: Run cargo fmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
# - name: Run cargo clippy
|
||||
# uses: actions-rs/cargo@v1
|
||||
# with:
|
||||
# command: clippy
|
||||
# args: -- -D warnings
|
||||
- name: Run cargo clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
|
|
|
@ -116,7 +116,7 @@ async fn handle_request(req: Request<Body>) -> Result<Response<Body>, Infallible
|
|||
}
|
||||
Ok(bytes) => bytes,
|
||||
};
|
||||
*out_response.body_mut() = Body::from((&bytes[..]).to_vec());
|
||||
*out_response.body_mut() = Body::from(bytes);
|
||||
}
|
||||
Ok(out_response)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::cmp;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
use log;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing as log;
|
||||
|
||||
|
@ -231,7 +229,7 @@ impl RateLimit {
|
|||
if let (Some(limit_header), Some(count_header)) = (limit_header_opt, count_header_opt) {
|
||||
{
|
||||
let buckets = self.buckets.upgradable_read();
|
||||
if !buckets_require_updating(limit_header, &*buckets) {
|
||||
if !buckets_require_updating(limit_header, &buckets) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
use log;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing as log;
|
||||
#[cfg(feature = "tracing")]
|
||||
|
@ -54,7 +52,7 @@ impl RegionalRequester {
|
|||
.get_or_insert_with(method_id, || RateLimit::new(RateLimitType::Method));
|
||||
|
||||
// Rate limit.
|
||||
let rate_limit = RateLimit::acquire_both(&self.app_rate_limit, &*method_rate_limit);
|
||||
let rate_limit = RateLimit::acquire_both(&self.app_rate_limit, &method_rate_limit);
|
||||
#[cfg(feature = "tracing")]
|
||||
let rate_limit = rate_limit.instrument(tracing::info_span!("rate_limit"));
|
||||
rate_limit.await;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
use log;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing as log;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ async_tests! {
|
|||
let sum = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "ma5tery");
|
||||
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 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..=1000).contains(&s), "Unexpected ma5tery score: {}.", s);
|
||||
Ok(())
|
||||
|
@ -27,7 +27,7 @@ async_tests! {
|
|||
let sum = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "ma5tery");
|
||||
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 p = RIOT_API.champion_mastery_v4().get_all_champion_masteries(ROUTE, &sum.id);
|
||||
let s = p.await.map_err(|e| e.to_string())?;
|
||||
rassert!(s.len() >= 142, "Expected masteries: {}.", s.len());
|
||||
Ok(())
|
||||
|
|
|
@ -53,13 +53,13 @@ async_tests! {
|
|||
tft_combo: async {
|
||||
let top_players = RIOT_API.tft_league_v1().get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
|
||||
let top_players = top_players.await.map_err(|e| e.to_string())?;
|
||||
rassert!(0 < top_players.len());
|
||||
rassert!(!top_players.is_empty());
|
||||
let top_player_entry = &top_players[0];
|
||||
let top_player = RIOT_API.tft_summoner_v1().get_by_summoner_id(ROUTE, &*top_player_entry.summoner_id);
|
||||
let top_player = RIOT_API.tft_summoner_v1().get_by_summoner_id(ROUTE, &top_player_entry.summoner_id);
|
||||
let top_player = top_player.await.map_err(|e| e.to_string())?;
|
||||
println!("Top player is {} with `puuid` {}.", top_player.name, top_player.puuid);
|
||||
let match_ids = RIOT_API.tft_match_v1().get_match_ids_by_puuid(
|
||||
ROUTE.to_regional(), &*top_player.puuid, Some(10), None, None, None);
|
||||
ROUTE.to_regional(), &top_player.puuid, Some(10), None, None, None);
|
||||
let match_ids = match_ids.await.map_err(|e| e.to_string())?;
|
||||
tft_match_v1_get(ROUTE.to_regional(), &*match_ids).await?;
|
||||
Ok(())
|
||||
|
|
|
@ -40,7 +40,7 @@ async_tests! {
|
|||
// Spot check 10% for `player-data`.
|
||||
for entry in leaderboard.iter().step_by(10)
|
||||
{
|
||||
let _player_data = RIOT_API.lol_challenges_v1().get_player_data(ROUTE, &*entry.puuid)
|
||||
let _player_data = RIOT_API.lol_challenges_v1().get_player_data(ROUTE, &entry.puuid)
|
||||
.await.map_err(|e| format!("Failed to get player data PUUID {}: {}", entry.puuid, e))?;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,10 @@ async_tests! {
|
|||
// summoner must have double-up rank.
|
||||
league_getforsummoner_tftbug: async {
|
||||
// TODO(mingwei): get summoner from leaderboard to avoid updating this all the time.
|
||||
const SUMMONER_NAME: &'static str = "Vincentscc";
|
||||
const SUMMONER_NAME: &str = "Vincentscc";
|
||||
let summoner_fut = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, SUMMONER_NAME);
|
||||
let summoner = summoner_fut.await.map_err(|e| e.to_string())?.ok_or_else(|| format!("Failed to get \"{}\"", SUMMONER_NAME))?;
|
||||
let league_fut = RIOT_API.league_v4().get_league_entries_for_summoner(ROUTE, &*summoner.id);
|
||||
let league_fut = RIOT_API.league_v4().get_league_entries_for_summoner(ROUTE, &summoner.id);
|
||||
let leagues = league_fut.await.map_err(|e| e.to_string())?;
|
||||
let tft_league = leagues.iter().find(|league| QueueType::RANKED_TFT_DOUBLE_UP == league.queue_type);
|
||||
rassert!(tft_league.is_some());
|
||||
|
|
|
@ -23,7 +23,7 @@ pub async fn league_v4_match_v5_latest_combo(route: PlatformRoute) -> Result<(),
|
|||
.get_challenger_league(route, QueueType::RANKED_SOLO_5x5);
|
||||
let challenger_league = challenger_future.await.map_err(|e| e.to_string())?;
|
||||
|
||||
if &QueueType::RANKED_SOLO_5x5 != &challenger_league.queue {
|
||||
if QueueType::RANKED_SOLO_5x5 != challenger_league.queue {
|
||||
return Err(format!("Unexpected `queue`: {}", challenger_league.queue));
|
||||
}
|
||||
if challenger_league.entries.is_empty() {
|
||||
|
@ -42,7 +42,7 @@ pub async fn league_v4_match_v5_latest_combo(route: PlatformRoute) -> Result<(),
|
|||
|
||||
let match_ids_future = RIOT_API.match_v5().get_match_ids_by_puuid(
|
||||
route.to_regional(),
|
||||
&*summoner_info.puuid,
|
||||
&summoner_info.puuid,
|
||||
Some(5),
|
||||
None,
|
||||
None,
|
||||
|
|
Loading…
Reference in New Issue