Skip to content

Commit 4388b07

Browse files
authored
More clippy and rustfmt things (#1278)
More linting and uniform code style reduces the things to watch out for in review. I'm running a nightly toolchain locally now, and have noticed some extra lints from that. Also enabled one extra clippy lint via `Cargo.toml`.
2 parents 3fd0357 + 70b5c3b commit 4388b07

File tree

25 files changed

+180
-203
lines changed

25 files changed

+180
-203
lines changed

bridge/svix-bridge/src/config/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{
22
borrow::Cow,
33
collections::HashMap,
44
convert::Infallible,
5+
fmt,
56
io::{Error, ErrorKind},
67
net::SocketAddr,
78
num::NonZeroUsize,
@@ -121,14 +122,14 @@ pub enum LogLevel {
121122
Trace,
122123
}
123124

124-
impl ToString for LogLevel {
125-
fn to_string(&self) -> String {
125+
impl fmt::Display for LogLevel {
126+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
126127
match self {
127128
Self::Info => Level::INFO,
128129
Self::Debug => Level::DEBUG,
129130
Self::Trace => Level::TRACE,
130131
}
131-
.to_string()
132+
.fmt(f)
132133
}
133134
}
134135

server/.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
allow-mixed-uninlined-format-args = false

server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ macro_use_imports = "warn"
1515
mut_mut = "warn"
1616
nonstandard_macro_braces = "warn"
1717
todo = "warn"
18+
uninlined_format_args = "warn"
1819

1920
[profile.dev.package]
2021
quote = { opt-level = 2 }

server/svix-server/src/cfg.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-FileCopyrightText: © 2022 Svix Authors
22
// SPDX-License-Identifier: MIT
33

4-
use std::{borrow::Cow, collections::HashMap, net::SocketAddr, sync::Arc, time::Duration};
4+
use std::{borrow::Cow, collections::HashMap, fmt, net::SocketAddr, sync::Arc, time::Duration};
55

66
use figment::{
77
providers::{Env, Format, Toml},
@@ -12,7 +12,10 @@ use serde::{Deserialize, Deserializer};
1212
use tracing::Level;
1313
use validator::{Validate, ValidationError};
1414

15-
use crate::{core::cryptography::Encryption, core::security::JwtSigningConfig, error::Result};
15+
use crate::{
16+
core::{cryptography::Encryption, security::JwtSigningConfig},
17+
error::Result,
18+
};
1619

1720
fn deserialize_main_secret<'de, D>(deserializer: D) -> Result<Encryption, D::Error>
1821
where
@@ -365,16 +368,17 @@ impl std::fmt::Display for Environment {
365368
}
366369
}
367370

368-
impl ToString for LogLevel {
369-
fn to_string(&self) -> String {
371+
impl fmt::Display for LogLevel {
372+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
370373
match self {
371374
Self::Info => Level::INFO,
372375
Self::Debug => Level::DEBUG,
373376
Self::Trace => Level::TRACE,
374377
}
375-
.to_string()
378+
.fmt(f)
376379
}
377380
}
381+
378382
pub fn load() -> Result<Arc<ConfigurationInner>> {
379383
if let Ok(db_url) = std::env::var("DATABASE_URL") {
380384
// If we have DATABASE_URL set, we should potentially use it.

server/svix-server/src/core/message_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl AppEndpointKey {
209209
// FIXME: Rewrite doc comment when AppEndpointValue members are known
210210
/// Returns a key for fetching all cached endpoints for a given organization and application.
211211
pub fn new(org: &OrganizationId, app: &ApplicationId) -> AppEndpointKey {
212-
AppEndpointKey(format!("SVIX_CACHE_APP_v3_{}_{}", org, app))
212+
AppEndpointKey(format!("SVIX_CACHE_APP_v3_{org}_{app}"))
213213
}
214214
}
215215

server/svix-server/src/core/webhook_http_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl RequestBuilder {
381381
let uri = self.uri.unwrap();
382382
let authority = uri.authority().expect("Missing authority");
383383
let host = match authority.port() {
384-
Some(port) => format!("{}:{}", authority.host(), port),
384+
Some(port) => format!("{}:{port}", authority.host()),
385385
None => authority.host().to_string(),
386386
};
387387

server/svix-server/src/db/models/application.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
// SPDX-FileCopyrightText: © 2022 Svix Authors
22
// SPDX-License-Identifier: MIT
33

4-
use crate::core::types::{
5-
ApplicationId, ApplicationIdOrUid, ApplicationUid, BaseId, OrganizationId,
6-
};
7-
use crate::error;
84
use chrono::Utc;
9-
use sea_orm::ActiveValue::Set;
10-
use sea_orm::ConnectionTrait;
11-
use sea_orm::{entity::prelude::*, Condition};
5+
use sea_orm::{entity::prelude::*, ActiveValue::Set, Condition};
126

137
use super::applicationmetadata;
8+
use crate::{
9+
core::types::{ApplicationId, ApplicationIdOrUid, ApplicationUid, BaseId, OrganizationId},
10+
error,
11+
};
1412

1513
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
1614
#[sea_orm(table_name = "application")]

server/svix-server/src/db/models/applicationmetadata.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// SPDX-FileCopyrightText: © 2022 Svix Authors
22
// SPDX-License-Identifier: MIT
3-
use crate::core::types::ApplicationId;
43

5-
use crate::core::types::metadata::Metadata;
6-
use crate::error;
74
use chrono::Utc;
8-
use sea_orm::entity::prelude::*;
9-
use sea_orm::sea_query::OnConflict;
10-
use sea_orm::ActiveValue::Set;
11-
use sea_orm::{ConnectionTrait, TryIntoModel};
5+
use sea_orm::{entity::prelude::*, sea_query::OnConflict, ActiveValue::Set, TryIntoModel};
6+
7+
use crate::{
8+
core::types::{metadata::Metadata, ApplicationId},
9+
error,
10+
};
1211

1312
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
1413
#[sea_orm(table_name = "applicationmetadata")]

server/svix-server/src/db/models/endpoint.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// SPDX-FileCopyrightText: © 2022 Svix Authors
22
// SPDX-License-Identifier: MIT
33

4-
use crate::core::types::{
5-
ApplicationId, BaseId, EndpointHeaders, EndpointId, EndpointIdOrUid, EndpointSecretInternal,
6-
EndpointUid, EventChannelSet, EventTypeNameSet, ExpiringSigningKeys,
7-
};
8-
use crate::error;
94
use chrono::Utc;
10-
use sea_orm::ActiveValue::Set;
11-
use sea_orm::{entity::prelude::*, Condition};
12-
use sea_orm::{ConnectionTrait, IntoActiveModel};
5+
use sea_orm::{entity::prelude::*, ActiveValue::Set, Condition, IntoActiveModel};
136

147
use super::endpointmetadata;
8+
use crate::{
9+
core::types::{
10+
ApplicationId, BaseId, EndpointHeaders, EndpointId, EndpointIdOrUid,
11+
EndpointSecretInternal, EndpointUid, EventChannelSet, EventTypeNameSet,
12+
ExpiringSigningKeys,
13+
},
14+
error,
15+
};
1516

1617
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
1718
#[sea_orm(table_name = "endpoint")]

server/svix-server/src/db/models/endpointmetadata.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// SPDX-FileCopyrightText: © 2022 Svix Authors
22
// SPDX-License-Identifier: MIT
3-
use crate::core::types::EndpointId;
4-
5-
use crate::core::types::metadata::Metadata;
6-
use crate::error;
73

84
use chrono::Utc;
9-
use sea_orm::entity::prelude::*;
10-
use sea_orm::sea_query::OnConflict;
11-
use sea_orm::ActiveValue::Set;
12-
use sea_orm::{ConnectionTrait, TryIntoModel};
5+
use sea_orm::{entity::prelude::*, sea_query::OnConflict, ActiveValue::Set, TryIntoModel};
6+
7+
use crate::{
8+
core::types::{metadata::Metadata, EndpointId},
9+
error,
10+
};
1311

1412
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
1513
#[sea_orm(table_name = "endpointmetadata")]

0 commit comments

Comments
 (0)