Skip to content

Commit

Permalink
server: Enforce usage of inlined format! arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte committed Mar 19, 2024
1 parent 3fd0357 commit c197046
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 75 deletions.
1 change: 1 addition & 0 deletions server/.clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allow-mixed-uninlined-format-args = false
1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ macro_use_imports = "warn"
mut_mut = "warn"
nonstandard_macro_braces = "warn"
todo = "warn"
uninlined_format_args = "warn"

[profile.dev.package]
quote = { opt-level = 2 }
Expand Down
2 changes: 1 addition & 1 deletion server/svix-server/src/core/message_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl AppEndpointKey {
// FIXME: Rewrite doc comment when AppEndpointValue members are known
/// Returns a key for fetching all cached endpoints for a given organization and application.
pub fn new(org: &OrganizationId, app: &ApplicationId) -> AppEndpointKey {
AppEndpointKey(format!("SVIX_CACHE_APP_v3_{}_{}", org, app))
AppEndpointKey(format!("SVIX_CACHE_APP_v3_{org}_{app}"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/svix-server/src/core/webhook_http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl RequestBuilder {
let uri = self.uri.unwrap();
let authority = uri.authority().expect("Missing authority");
let host = match authority.port() {
Some(port) => format!("{}:{}", authority.host(), port),
Some(port) => format!("{}:{port}", authority.host()),
None => authority.host().to_string(),
};

Expand Down
4 changes: 2 additions & 2 deletions server/svix-server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ impl fmt::Display for HttpError {
match &self.body {
HttpErrorBody::Standard(StandardHttpError { code, detail }) => write!(
f,
"status={} code=\"{}\" detail=\"{}\"",
self.status, code, detail
"status={} code=\"{code}\" detail=\"{detail}\"",
self.status
),

HttpErrorBody::Validation(ValidationHttpError { detail }) => {
Expand Down
5 changes: 2 additions & 3 deletions server/svix-server/src/queue/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,11 @@ async fn new_pair_inner(
if let Err(e) = consumer_group_resp {
if !e.to_string().contains("BUSYGROUP") {
panic!(
"error creating consumer group or stream: {:?}, {:?}, {:?}, {:?}, {:?}",
"error creating consumer group or stream: {:?}, {:?}, {:?}, {:?}, {e:?}",
e.kind(),
e.detail(),
e.code(),
e.category(),
e
e.category()
)
};
}
Expand Down
2 changes: 1 addition & 1 deletion server/svix-server/src/v1/endpoints/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn app_portal_access(
let login_key = base64::encode(login_key);

// Included for API compatibility, but this URL will not be useful
let url = format!("{}/login#key={}", &cfg.internal.app_portal_url, login_key);
let url = format!("{}/login#key={login_key}", &cfg.internal.app_portal_url);

Ok(Json(AppPortalAccessOut::from(DashboardAccessOut {
url,
Expand Down
11 changes: 4 additions & 7 deletions server/svix-server/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ impl FailureCacheKey {
app_id: &ApplicationId,
endp_id: &EndpointId,
) -> FailureCacheKey {
FailureCacheKey(format!(
"SVIX_FAILURE_CACHE_{}_{}_{}",
org_id, app_id, endp_id
))
FailureCacheKey(format!("SVIX_FAILURE_CACHE_{org_id}_{app_id}_{endp_id}"))
}
}

Expand Down Expand Up @@ -177,7 +174,7 @@ fn sign_msg(
EndpointSecretType::Hmac256 => "v1",
EndpointSecretType::Ed25519 => "v1a",
};
format!("{},{}", version, base64::encode(sig))
format!("{version},{}", base64::encode(sig))
})
.collect::<Vec<String>>()
.join(" ")
Expand Down Expand Up @@ -579,8 +576,8 @@ async fn handle_failed_dispatch(
.await?
.ok_or_else(|| {
Error::generic(format!(
"Endpoint not found {} {}",
app_id, &msg_task.endpoint_id
"Endpoint not found {app_id} {}",
&msg_task.endpoint_id
))
})?;

Expand Down
22 changes: 11 additions & 11 deletions server/svix-server/tests/it/e2e_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async fn test_list_attempted_messages() {

let list_2_uid: ListResponse<EndpointMessageOut> = client
.get(
&format!("api/v1/app/{}/endpoint/{}/msg/", app_id, "test"),
&format!("api/v1/app/{app_id}/endpoint/{}/msg/", "test"),
StatusCode::OK,
)
.await
Expand Down Expand Up @@ -390,7 +390,7 @@ async fn test_message_attempts() {

for i in list.data.iter() {
assert_eq!(i.status, msg_status);
println!("{} {}", i.response_status_code, status_code);
println!("{} {status_code}", i.response_status_code);
assert_eq!(
i.response_status_code,
TryInto::<i16>::try_into(status_code.as_u16()).unwrap()
Expand Down Expand Up @@ -466,7 +466,7 @@ async fn test_message_attempts_empty_retry_schedule() {

for i in list.data.iter() {
assert_eq!(i.status, msg_status);
println!("{} {}", i.response_status_code, status_code);
println!("{} {status_code}", i.response_status_code);
assert_eq!(
i.response_status_code,
TryInto::<i16>::try_into(status_code.as_u16()).unwrap()
Expand Down Expand Up @@ -524,7 +524,7 @@ async fn test_pagination_by_endpoint() {
for endp_id in eps.iter().map(|ep| &ep.id) {
let list: ListResponse<MessageAttemptOut> = client
.get(
&format!("api/v1/app/{}/attempt/endpoint/{}/", app.id, endp_id),
&format!("api/v1/app/{}/attempt/endpoint/{endp_id}/", app.id),
StatusCode::OK,
)
.await
Expand Down Expand Up @@ -713,7 +713,7 @@ async fn test_pagination_by_msg() {
for endp_id in eps.iter().map(|ep| &ep.id) {
let list: ListResponse<MessageAttemptOut> = client
.get(
&format!("api/v1/app/{}/attempt/endpoint/{}/", app.id, endp_id),
&format!("api/v1/app/{}/attempt/endpoint/{endp_id}/", app.id),
StatusCode::OK,
)
.await
Expand All @@ -726,8 +726,8 @@ async fn test_pagination_by_msg() {
let list_filtered: ListResponse<MessageAttemptOut> = client
.get(
&format!(
"api/v1/app/{}/attempt/endpoint/{}/?channel=news",
app.id, endp_id
"api/v1/app/{}/attempt/endpoint/{endp_id}/?channel=news",
app.id
),
StatusCode::OK,
)
Expand Down Expand Up @@ -966,8 +966,8 @@ async fn test_pagination_forward_and_back() {
let mut out: ListResponse<MessageAttemptOut> = client
.get(
&format!(
"api/v1/app/{}/attempt/endpoint/{}/?limit=10{}",
app.id, ep.id, iter_suffix
"api/v1/app/{}/attempt/endpoint/{}/?limit=10{iter_suffix}",
app.id, ep.id
),
StatusCode::OK,
)
Expand Down Expand Up @@ -996,8 +996,8 @@ async fn test_pagination_forward_and_back() {
let mut out: ListResponse<MessageAttemptOut> = client
.get(
&format!(
"api/v1/app/{}/attempt/endpoint/{}/?limit=10{}",
app.id, ep.id, iter_suffix
"api/v1/app/{}/attempt/endpoint/{}/?limit=10{iter_suffix}",
app.id, ep.id
),
StatusCode::OK,
)
Expand Down
Loading

0 comments on commit c197046

Please sign in to comment.