Skip to content

Commit

Permalink
chore: clippies
Browse files Browse the repository at this point in the history
  • Loading branch information
mautamu committed Mar 17, 2024
1 parent 22b018f commit f15eae8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
8 changes: 2 additions & 6 deletions src/model/auth/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub(crate) async fn make_move<'v>(
let v2_verif = match &movesub.token_v2 {
None => false,
Some(mv_tv2) => {
if mv_tv2 == "" {
if mv_tv2.is_empty() {
return std::result::Result::Ok(Json(StatusWrapper {
code: 4004,
message: "Captcha required.".to_string(),
Expand All @@ -322,11 +322,7 @@ pub(crate) async fn make_move<'v>(
dbg!(e);
crate::Error::InternalServerError {}
})?;
if r_v2_result.score > 0.5 {
true
} else {
false
}
r_v2_result.score > 0.5
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/model/discord/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(crate) async fn callback(
match userinfo {
Ok(user_info) => {
let new_user = UpsertableUser {
uname: String::from(user_info.name()),
uname: user_info.name(),
platform: String::from("discord"),
};
match conn
Expand Down
2 changes: 1 addition & 1 deletion src/model/ratings/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Ratings {
let gameTurns = Self::fromarr(stat.gameTurns, [0, 5, 10, 25, 40]);
let mvps = Self::fromarr(stat.mvps, [0, 1, 5, 10, 25]);
let streak = Self::fromarr(stat.streak, [0, 3, 5, 10, 25]);
let mut numbers = vec![totalTurns, gameTurns, mvps, streak]; // awards
let mut numbers = [totalTurns, gameTurns, mvps, streak]; // awards
numbers.sort_unstable();
let mid = ((numbers[1] as f32 + numbers[2] as f32) / 2_f32).round() as i32;
let overall: i32 = mid;
Expand Down
12 changes: 7 additions & 5 deletions src/model/reddit/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ pub(crate) async fn callback(

let uname_ban_chk = uname.clone();
// We also want to ensure the user has a validated email with Reddit:
if !user_info
let has_verified_email = user_info
.get("has_verified_email")
.unwrap_or_else(|| {
dbg!("Error serializing user email check");
&serde_json::json!(false)
})
.as_bool()
.unwrap_or(false)
.unwrap_or(false);
if !has_verified_email
&& conn
.run(move |c| {
bans::table
Expand Down Expand Up @@ -115,15 +116,16 @@ pub(crate) async fn callback(

dbg!(user_info.get("is_suspended"));

if user_info
let is_suspended = user_info
.get("is_suspended")
.unwrap_or_else(|| {
dbg!("Error: unable to know if user was suspended");
&serde_json::json!(false)
})
.as_bool()
.unwrap_or(false)
{
.unwrap_or(false);

if is_suspended {
conn.run(move |c| UpsertableUser::flag(uname_2_int, c))
.await
.map_err(|e| {
Expand Down
14 changes: 7 additions & 7 deletions src/ringmaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
fn unique(self: &mut Vec<T>) -> Self {
let mut seen: HashSet<T> = HashSet::new();
self.retain(|item| seen.insert(item.clone()));
return self.to_vec();
self.to_vec()
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ fn get_territories_by_submaps(

fn reassign_processed_territories(
eligible_teams: &Vec<i32>,
territory_pool: &mut Vec<TerritoryOwnersInsert>,
territory_pool: &mut [TerritoryOwnersInsert],
secondary_stats: &mut BTreeMap<i32, Stats>,
secondary_territory_stats: &mut Vec<TerritoryStats>,
turn_id: i32,
Expand Down Expand Up @@ -224,7 +224,7 @@ fn reassign_processed_territories(
// Update territory stats to include this new team
secondary_territory_stats.push(TerritoryStats {
team: *team,
turn_id: turn_id,
turn_id,
territory: territory_pool[territory_pointer].territory_id,
..TerritoryStats::default()
});
Expand Down Expand Up @@ -276,7 +276,7 @@ fn process_territories(
// If this is for the respawn map and a team has moved to main map, then we vacate
// their territories; we do this by discarding their moves and on territories w/ 0 moves
// reassigning to NCAA (id 0)
if must_vacate.len() > 0 {
if !must_vacate.is_empty() {
players.retain(|x| !must_vacate.contains(&x.team));
}

Expand Down Expand Up @@ -314,7 +314,7 @@ fn process_territories(
dbg!("Zero Team");

// In the case that respawn = true and the owning team
let territory_owner_id = if must_vacate.len() > 0 {
let territory_owner_id = if !must_vacate.is_empty() {
0
} else {
territory.owner_id
Expand Down Expand Up @@ -944,7 +944,7 @@ fn runtime() -> Result<(), diesel::result::Error> {
.unique()
.iter()
.filter(|v| !alive_teams.contains(*v))
.map(|v| v.clone())
.copied()
.collect();
// Now that we know which teams died, query to see which are eligible for respawn
let mut eligible_eliminated_teams =
Expand All @@ -965,7 +965,7 @@ fn runtime() -> Result<(), diesel::result::Error> {
alive_teams,
);

if eligible_eliminated_teams.len() > 0 {
if !eligible_eliminated_teams.is_empty() {
// Shuffle the pool of eliminated teams
shuffle_array(&mut eligible_eliminated_teams);
// Gather a pool of available reassignable territories
Expand Down
2 changes: 1 addition & 1 deletion src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl TerritoryOwnersInsert {
previous_owner_id: territory.owner_id,
random_number: random_number.unwrap_or(0_f64),
mvp,
is_respawn: is_respawn,
is_respawn,
}
}

Expand Down

0 comments on commit f15eae8

Please sign in to comment.