Skip to content

Commit

Permalink
style: cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Brayan-724 committed Sep 23, 2024
1 parent 5b5dd97 commit 13897a3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/api/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub async fn middleware(

if header_key
.as_ref()
.is_some_and(|k| k.to_str().unwrap() == &secrets.api_key)
.is_some_and(|k| k.to_str().unwrap() == secrets.api_key)
{
return Ok(next.run(req).await);
}
Expand Down
8 changes: 4 additions & 4 deletions src/bot/commands/krate/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub async fn fetch_crate(client: &Client, crate_name: String) -> reqwest::Result

if let Ok(err) = serde_json::from_str::<CratesError>(&res) {
if let Some(CratesErrorDetail { detail }) = err.errors.first() {
return Ok(format!("{detail}"));
return Ok(detail.to_string());
}
}

Expand All @@ -83,7 +83,7 @@ pub async fn fetch_crate(client: &Client, crate_name: String) -> reqwest::Result
}) = serde_json::from_str::<CratesIO>(&res)
.inspect_err(|e| tracing::error!("Serde Crates.io: {e:?}"))
else {
return Ok(format!("No se pudo deserializar la respuesta"));
return Ok("No se pudo deserializar la respuesta".to_string());
};

let res = MESSAGE
Expand Down Expand Up @@ -152,14 +152,14 @@ pub async fn search_crate(

if let Ok(err) = serde_json::from_str::<CratesError>(&res) {
if let Some(CratesErrorDetail { detail }) = err.errors.first() {
return Ok(Err(format!("{detail}")));
return Ok(Err(detail.to_string()));
}
}

let Ok(CargoSearch { crates }) = serde_json::from_str::<CargoSearch>(&res)
.inspect_err(|e| tracing::error!("Serde Crates.io: {e:?}"))
else {
return Ok(Err(format!("No se pudo deserializar la respuesta")));
return Ok(Err("No se pudo deserializar la respuesta".to_string()));
};

let crates = crates
Expand Down
2 changes: 1 addition & 1 deletion src/bot/commands/suggest/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub async fn nueva(
#[description = "Cuentanos acerca de tu sugerencia"] contenido: String,
) -> Result<(), bot::Error> {
info!("Running create suggestion");
let data = ctx.clone().data();
let data = ctx.data();

let msg_channel = ChannelId::new(data.secrets.channel_suggest);

Expand Down
4 changes: 2 additions & 2 deletions src/bot/events/anti_spam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub async fn message(ctx: &Context, new_message: &Message) -> Result<bool, bot::
.await?;
let mut message_tracker = MESSAGE_TRACKER.lock().await;
let time = 604800;
let channel_id = new_message.channel_id.clone();
let channel_id = new_message.channel_id;

if let Some(last_message) = message_tracker.iter().last() {
if last_message.author_id == author_id
Expand Down Expand Up @@ -143,7 +143,7 @@ async fn delete_spam_messages(

let messages = channel.messages(&ctx.http, GetMessages::new()).await?;
for message in messages {
if message.author.id == author_id && &*message.content == &*message_content {
if message.author.id == author_id && &*message.content == message_content {
message.delete(&ctx.http).await?;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/bot/events/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub async fn message(ctx: &Context, msg: &Message) -> Result<bool, bot::Error> {

let parts: Vec<&str> = Regex::new(r"[ \n]")
.unwrap()
.splitn(&*msg.content, 2)
.splitn(&msg.content, 2)
.collect();

if parts.len() < 2 {
Expand Down Expand Up @@ -196,7 +196,7 @@ pub async fn message(ctx: &Context, msg: &Message) -> Result<bool, bot::Error> {
language = LANGUAGE_ALIASES
.iter()
.find_map(|(key, value)| {
if key.to_string() == language {
if *key == language {
Some(value.to_string())
} else {
None
Expand All @@ -221,7 +221,7 @@ pub async fn message(ctx: &Context, msg: &Message) -> Result<bool, bot::Error> {
.iter()
.find(|&&(lang, _)| lang == language)
.map(|&(_, tmpl)| tmpl)
.unwrap_or(&"{code}");
.unwrap_or("{code}");

let regex_str = MAIN_REGEX_TEMPLATES
.iter()
Expand Down
8 changes: 4 additions & 4 deletions src/bot/events/compile/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub async fn compile_code(language: String, code: String, args: String) -> Optio
Client::new()
.post(format!(
"https://api.paiza.io/runners/create?source_code={}&language={}&api_key=guest{}",
encode(&*code),
encode(&*language),
encode(&code),
encode(&language),
if args.is_empty() {
"".to_string()
} else {
Expand All @@ -46,7 +46,7 @@ pub async fn check_status(runner_id: String) -> Option<RunnerResponse> {
Client::new()
.get(format!(
"https://api.paiza.io/runners/get_status?id={}&api_key=guest",
encode(&*runner_id)
encode(&runner_id)
))
.send()
.await
Expand All @@ -61,7 +61,7 @@ pub async fn check_details(runner_id: String) -> Option<RunnerDetails> {
Client::new()
.get(format!(
"https://api.paiza.io/runners/get_details?id={}&api_key=guest",
encode(&*runner_id)
encode(&runner_id)
))
.send()
.await
Expand Down
2 changes: 1 addition & 1 deletion src/bot/events/new_members_mention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub async fn message(ctx: &Context, msg: &Message) -> Result<bool, bot::Error> {
.unwrap()
.members
.iter()
.filter_map(|(_, v)| v.roles.contains(&NEW_MEMBERS_ROLE_ID).then(|| v.clone()))
.filter(|&(_, v)| v.roles.contains(&NEW_MEMBERS_ROLE_ID)).map(|(_, v)| v.clone())
.collect::<Vec<_>>();

tracing::info!("New Members: {}", members.len());
Expand Down

0 comments on commit 13897a3

Please sign in to comment.