Skip to content

Commit

Permalink
autofix cargo clippy lints
Browse files Browse the repository at this point in the history
gburgessiv committed May 27, 2023
1 parent 71c0b9d commit e231cf9
Showing 4 changed files with 24 additions and 31 deletions.
33 changes: 13 additions & 20 deletions src/discord.rs
Original file line number Diff line number Diff line change
@@ -277,7 +277,7 @@ impl BlamelistCache {
// iteration of this loop. If that happens, eh. It's a race anyway.
}
Entry::Vacant(x) => {
x.insert(storage.find_userids_for(&email)?);
x.insert(storage.find_userids_for(email)?);
}
}
}
@@ -295,10 +295,10 @@ impl BlamelistCache {
let mut emails: Vec<&Email> = Vec::new();
let mut user_ids: HashSet<UserId> = HashSet::new();
for email in blamelist {
let users_to_ping = self.email_id_mappings.get(&email).unwrap();
let users_to_ping = self.email_id_mappings.get(email).unwrap();
let mut pinged_anyone = false;
for u in users_to_ping {
if guild_members.contains_key(&u) {
if guild_members.contains_key(u) {
pinged_anyone = true;
user_ids.insert(*u);
}
@@ -337,7 +337,7 @@ fn url_escape_bot_name(bot_name: &str) -> Cow<'_, str> {
if !bot_name.contains(' ') {
Cow::Borrowed(bot_name)
} else {
Cow::Owned(bot_name.replace(" ", "%20"))
Cow::Owned(bot_name.replace(' ', "%20"))
}
}

@@ -379,7 +379,7 @@ impl ChannelServer {
}

self.status_channel
.edit_message(http, prev_data.id, |m| m.content(&*data))
.edit_message(http, prev_data.id, |m| m.content(data))
.await?;

prev_data.last_value = data.to_owned();
@@ -388,7 +388,7 @@ impl ChannelServer {

let discord_message = self
.status_channel
.send_message(http, |m| m.content(&*data))
.send_message(http, |m| m.content(data))
.await?;
existing_messages.push(ServerUIMessage {
last_value: data.to_owned(),
@@ -457,7 +457,7 @@ impl ChannelServer {
http,
&next_breakage.build.blamelist,
self.guild,
&*self.storage,
&self.storage,
)
.await?;
}
@@ -821,7 +821,7 @@ impl serenity::client::EventHandler for MessageHandler {
loop {
info!("Setting up serving for guild #{}", guild_id);
if let Err(x) = server
.serve(&*http, &mut pubsub_reader, &mut should_exit)
.serve(&http, &mut pubsub_reader, &mut should_exit)
.await
{
error!("Failed serving guild #{}: {}", guild_id, x);
@@ -1019,7 +1019,7 @@ fn duration_to_shorthand(dur: chrono::Duration) -> String {
let d = dur.num_days();
return format!("{} {}", d, if d == 1 { "day" } else { "days" });
}
return format!("{} weeks", dur.num_weeks());
format!("{} weeks", dur.num_weeks())
}

// Eh.
@@ -1184,10 +1184,7 @@ impl StatusUIUpdater {
for (category_name, bots) in categorized {
let mut failed_bots: Vec<_> = bots
.iter()
.filter_map(|(name, bot)| match &bot.status.first_failing_build {
None => None,
Some(x) => Some((*name, x.id, x.completion_time)),
})
.filter_map(|(name, bot)| bot.status.first_failing_build.as_ref().map(|x| (*name, x.id, x.completion_time)))
.collect();

if failed_bots.is_empty() {
@@ -1294,11 +1291,7 @@ impl UpdateUIUpdater {
.bots
.iter()
.filter_map(|(id, bot)| {
if let Some(x) = &bot.status.first_failing_build {
Some((id, x))
} else {
None
}
bot.status.first_failing_build.as_ref().map(|x| (id, x))
})
.collect();

@@ -1351,8 +1344,8 @@ async fn draw_ui(

looped_before = true;
pubsub.publish(
Arc::new(status_ui.draw_ui_with_snapshot(&*snapshot)),
&update_ui.get_updates(&*snapshot),
Arc::new(status_ui.draw_ui_with_snapshot(&snapshot)),
&update_ui.get_updates(&snapshot),
);
}
}
6 changes: 3 additions & 3 deletions src/greendragon.rs
Original file line number Diff line number Diff line change
@@ -36,10 +36,10 @@ where
.and_then(|x| x.error_for_status())
.with_context(|| format!("requesting {}", path))?;

Ok(resp
resp
.json()
.await
.with_context(|| format!("parsing {}", path))?)
.with_context(|| format!("parsing {}", path))
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
@@ -51,7 +51,7 @@ enum Color {
Yellow { flashing: bool },
}

const VALID_COLOR_VALUES: &'static [(&'static str, Color)] = &[
const VALID_COLOR_VALUES: &[(&str, Color)] = &[
// All of the aborted builds I can find are colored grey on the UI, so.
("aborted", Color::Disabled),
("aborted_anime", Color::Disabled),
10 changes: 5 additions & 5 deletions src/lab.rs
Original file line number Diff line number Diff line change
@@ -112,10 +112,10 @@ where
Ok(x) => x,
};

return Ok(resp
return resp
.json()
.await
.with_context(|| format!("parsing {}", url))?);
.with_context(|| format!("parsing {}", url));
}
}

@@ -257,7 +257,7 @@ impl<'de> serde::de::Deserialize<'de> for RawBuildbotTime {
where
E: serde::de::Error,
{
let secs = value as i64;
let secs = value;
match chrono::NaiveDateTime::from_timestamp_opt(secs, 0) {
Some(x) => Ok(RawBuildbotTime(x)),
None => Err(E::custom(format!("{} is an invalid timestamp", value))),
@@ -632,7 +632,7 @@ async fn resolve_builder_build_info(
let most_recent_build = resolve_completed_lab_build(client, &info.most_recent_build).await?;
let first_failing_build = match &info.first_failing_build {
None => None,
Some(x) => Some(resolve_completed_lab_build(client, &x).await?),
Some(x) => Some(resolve_completed_lab_build(client, x).await?),
};
Ok(Bot {
category: determine_bot_category(bot_info)
@@ -840,7 +840,7 @@ async fn perform_incremental_builder_sync(
.pending_builds
.iter()
.cloned()
.filter(|x| !fetched_ids.contains(&x)),
.filter(|x| !fetched_ids.contains(x)),
move |id| fetch_build_by_id(client.clone(), id),
)
.await?
6 changes: 3 additions & 3 deletions src/storage.rs
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ mod test {

{
let emails = storage.find_emails_for(id).expect("failed fetching emails");
assert_eq!(&emails, &[email.clone()]);
assert_eq!(&emails, &[email]);
}
}

@@ -230,7 +230,7 @@ mod test {

{
let emails = storage.find_emails_for(id).expect("failed fetching emails");
assert_eq!(&emails, &[email.clone()]);
assert_eq!(&emails, &[email]);
}
}

@@ -253,7 +253,7 @@ mod test {

for email in &emails {
let db_ids = storage
.find_userids_for(&email)
.find_userids_for(email)
.expect("failed fetching userids");
assert_eq!(&db_ids, &ids);
}

0 comments on commit e231cf9

Please sign in to comment.