Skip to content

Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.

chore: Fix clippy and lint (#1657)

Amaury37a86d78ee9f
diff --git a/backend/src/bin/prune_db.rs b/backend/src/bin/prune_db.rs
index 5c59ba8e..cf3701de 100644
--- a/backend/src/bin/prune_db.rs
+++ b/backend/src/bin/prune_db.rs
@@ -26,8 +26,7 @@ async fn main() -> Result<()> {
GROUP BY job_id
) e ON b.id = e.job_id
WHERE b.total_records = e.total_processed
- AND b.created_at <= current_date - interval '{} days'",
- days_old
+ AND b.created_at <= current_date - interval '{days_old} days'"
);
let job_ids_to_delete: Vec<(i32,)> = sqlx::query_as(&query).fetch_all(&pool).await?;
diff --git a/backend/src/http/v0/check_email/post.rs b/backend/src/http/v0/check_email/post.rs
index da06cb72..e748e679 100644
--- a/backend/src/http/v0/check_email/post.rs
+++ b/backend/src/http/v0/check_email/post.rs
@@ -69,7 +69,7 @@ impl CheckEmailRequest {
hello_name.clone(),
from_email.clone(),
smtp_port,
- smtp_timeout.clone(),
+ smtp_timeout,
retries,
)
} else {
@@ -83,7 +83,7 @@ impl CheckEmailRequest {
self.proxy.is_some(),
hello_name.clone(),
from_email.clone(),
- smtp_timeout.clone(),
+ smtp_timeout,
smtp_port,
retries,
);
diff --git a/backend/src/http/v1/bulk/get_results/mod.rs b/backend/src/http/v1/bulk/get_results/mod.rs
index 54b5049e..c1aace7b 100644
--- a/backend/src/http/v1/bulk/get_results/mod.rs
+++ b/backend/src/http/v1/bulk/get_results/mod.rs
@@ -82,7 +82,7 @@ async fn http_handler(
if total_processed < total_records as i64 {
return Err(ReacherResponseError::new(
StatusCode::BAD_REQUEST,
- format!("Job {} is still running, please try again later", job_id),
+ format!("Job {job_id} is still running, please try again later"),
)
.into());
}
diff --git a/backend/src/http/v1/check_email/post.rs b/backend/src/http/v1/check_email/post.rs
index 602efc8a..353611bb 100644
--- a/backend/src/http/v1/check_email/post.rs
+++ b/backend/src/http/v1/check_email/post.rs
@@ -67,9 +67,7 @@ async fn handle_without_worker(
// If we're in the Commercial License Trial, we also store the
// result by sending it to back to Reacher.
- send_to_reacher(Arc::clone(&config), &body.to_email, &result_ok)
- .await
- .map_err(ReacherResponseError::from)?;
+ send_to_reacher(Arc::clone(&config), &body.to_email, &result_ok).await?;
let result = result_ok.unwrap();
info!(target: LOG_TARGET, email=body.to_email, is_reachable=?result.is_reachable, "Done verification");
@@ -123,7 +121,7 @@ async fn handle_with_worker(
let mut consumer = channel
.basic_consume(
reply_queue.name().as_str(),
- format!("rpc.{}", correlation_id).as_str(),
+ format!("rpc.{correlation_id}").as_str(),
BasicConsumeOptions::default(),
FieldTable::default(),
)
diff --git a/backend/src/http/version/get.rs b/backend/src/http/version/get.rs
index a7fb0f32..eccf251b 100644
--- a/backend/src/http/version/get.rs
+++ b/backend/src/http/version/get.rs
@@ -54,7 +54,7 @@ mod tests {
assert_eq!(resp.status(), StatusCode::OK);
assert_eq!(
resp.body(),
- format!("{{\"version\":\"{}\"}}", CARGO_PKG_VERSION).as_str()
+ format!("{{\"version\":\"{CARGO_PKG_VERSION}\"}}").as_str()
);
}
}
diff --git a/core/src/haveibeenpwned.rs b/core/src/haveibeenpwned.rs
index 27fffe8a..f62746a9 100644
--- a/core/src/haveibeenpwned.rs
+++ b/core/src/haveibeenpwned.rs
@@ -25,10 +25,7 @@ const MAIN_API_URL: &str = "https://haveibeenpwned.com/api/v3/";
/// any breach.
pub async fn check_haveibeenpwned(to_email: &str, api_key: Option<String>) -> Option<bool> {
let client = Client::new();
- let url = format!(
- "{}breachedaccount/{}?truncateResponse=false",
- MAIN_API_URL, to_email
- );
+ let url = format!("{MAIN_API_URL}breachedaccount/{to_email}?truncateResponse=false");
let request = client
.get(&url)
diff --git a/core/src/mx/mod.rs b/core/src/mx/mod.rs
index 24389b41..f90a0bd9 100644
--- a/core/src/mx/mod.rs
+++ b/core/src/mx/mod.rs
@@ -153,8 +153,8 @@ pub fn is_mimecast(mx_host: &str) -> bool {
/// Check if the MX host is behind Proofpoint.
pub fn is_proofpoint(mx_host: &str) -> bool {
- let host = mx_host.to_lowercase();
- host.ends_with(".pphosted.com.") || host.ends_with("ppe-hosted.com.")
+ let host = mx_host.to_lowercase();
+ host.ends_with(".pphosted.com.") || host.ends_with("ppe-hosted.com.")
}
/// Check if the MX host is from Yahoo.
@@ -162,16 +162,16 @@ pub fn is_proofpoint(mx_host: &str) -> bool {
/// - mta7.am0.yahoodns.net.
/// - mx-eu.mail.am0.yahoodns.net.
pub fn is_yahoo(mx_host: &str) -> bool {
- mx_host.to_lowercase().ends_with(".yahoodns.net.")
+ mx_host.to_lowercase().ends_with(".yahoodns.net.")
}
#[cfg(test)]
mod tests {
- use super::*;
+ use super::*;
- #[test]
- fn proofpoint_detection_is_case_insensitive() {
- assert!(is_proofpoint("mx1.PPHOSTED.COM."));
- assert!(is_proofpoint("mx2.ppe-hosted.com."));
- }
+ #[test]
+ fn proofpoint_detection_is_case_insensitive() {
+ assert!(is_proofpoint("mx1.PPHOSTED.COM."));
+ assert!(is_proofpoint("mx2.ppe-hosted.com."));
+ }
}
diff --git a/core/src/smtp/connect.rs b/core/src/smtp/connect.rs
index 76a312b5..a27e1397 100644
--- a/core/src/smtp/connect.rs
+++ b/core/src/smtp/connect.rs
@@ -245,7 +245,7 @@ async fn smtp_is_catch_all<S: AsyncBufRead + AsyncWrite + Unpin + Send>(
.map(char::from)
.take(15)
.collect();
- let random_email = EmailAddress::new(format!("{}@{}", random_email, domain))?;
+ let random_email = EmailAddress::new(format!("{random_email}@{domain}"))?;
check_email_deliverability(smtp_transport, &random_email)
.await
diff --git a/core/src/util/sentry.rs b/core/src/util/sentry.rs
index 2314e5f6..3b1f00d9 100644
--- a/core/src/util/sentry.rs
+++ b/core/src/util/sentry.rs
@@ -82,7 +82,7 @@ fn error(err: SentryError, result: &CheckEmailOutput, backend_name: &str) {
},
level: Level::Error,
environment: Some("production".into()),
- release: Some(format!("v{}", CARGO_PKG_VERSION).into()),
+ release: Some(format!("v{CARGO_PKG_VERSION}").into()),
message: Some(format!("{result:#?}")),
server_name: Some(backend_name.to_string().into()),
transaction: Some(format!("check_email:{}", result.syntax.domain)),