From b8d23be313a2bb1d7b6118fec45cc1c80fa1ea8e Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Wed, 30 Jul 2025 14:49:38 +0200 Subject: [PATCH] Fix many clippy warnings This is because the tracing-attributes update made clippy look at those again. I've removed the `too_many_lines` lint, as it's not really useful and we ignore it most of the time anyway. --- Cargo.toml | 1 + crates/axum-utils/src/client_authorization.rs | 1 - crates/cli/src/commands/doctor.rs | 1 - crates/cli/src/commands/manage.rs | 1 - crates/cli/src/commands/server.rs | 1 - crates/cli/src/commands/syn2mas.rs | 1 - crates/cli/src/server.rs | 1 - crates/cli/src/telemetry/tokio.rs | 1 - crates/config/src/sections/secrets.rs | 1 + crates/handlers/src/admin/v1/mod.rs | 1 - crates/handlers/src/lib.rs | 1 - .../handlers/src/oauth2/authorization/mod.rs | 1 - crates/handlers/src/oauth2/discovery.rs | 1 - crates/handlers/src/oauth2/introspection.rs | 1 - crates/handlers/src/oauth2/token.rs | 2 -- crates/handlers/src/passwords.rs | 1 - crates/handlers/src/upstream_oauth2/cache.rs | 10 ++++-- .../handlers/src/upstream_oauth2/callback.rs | 2 +- .../handlers/src/views/register/password.rs | 2 +- crates/i18n/src/sprintf/formatter.rs | 2 +- crates/iana-codegen/src/generation.rs | 1 - crates/iana-codegen/src/main.rs | 1 - crates/iana/src/jose.rs | 9 ------ crates/iana/src/oauth.rs | 5 --- crates/jose/src/jwk/mod.rs | 1 - crates/listener/src/proxy_protocol/v1.rs | 1 - crates/listener/src/server.rs | 1 - crates/oauth2-types/src/registration/mod.rs | 2 -- crates/oauth2-types/src/response_type.rs | 1 - .../src/types/client_credentials.rs | 1 - crates/policy/src/lib.rs | 31 +++++++++++++++++++ crates/storage-pg/src/app_session.rs | 2 -- .../src/oauth2/authorization_grant.rs | 1 - crates/storage-pg/src/oauth2/client.rs | 2 -- .../src/upstream_oauth2/provider.rs | 1 - .../storage-pg/src/user/registration_token.rs | 1 - .../syn2mas/src/synapse_reader/config/oidc.rs | 1 - crates/tasks/src/new_queue.rs | 7 ++--- crates/templates/src/lib.rs | 8 +++++ 39 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 788a3bb1e..24e9cd25d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ all = { level = "deny", priority = -1 } pedantic = { level = "warn", priority = -1 } str_to_string = "deny" +too_many_lines = "allow" [workspace.lints.rustdoc] broken_intra_doc_links = "deny" diff --git a/crates/axum-utils/src/client_authorization.rs b/crates/axum-utils/src/client_authorization.rs index ed842590d..65d885853 100644 --- a/crates/axum-utils/src/client_authorization.rs +++ b/crates/axum-utils/src/client_authorization.rs @@ -368,7 +368,6 @@ where { type Rejection = ClientAuthorizationError; - #[allow(clippy::too_many_lines)] async fn from_request( req: Request, state: &S, diff --git a/crates/cli/src/commands/doctor.rs b/crates/cli/src/commands/doctor.rs index c7eb2768a..d39a5cd52 100644 --- a/crates/cli/src/commands/doctor.rs +++ b/crates/cli/src/commands/doctor.rs @@ -26,7 +26,6 @@ const DOCS_BASE: &str = "https://element-hq.github.io/matrix-authentication-serv pub(super) struct Options {} impl Options { - #[allow(clippy::too_many_lines)] pub async fn run(self, figment: &Figment) -> anyhow::Result { let _span = info_span!("cli.doctor").entered(); info!( diff --git a/crates/cli/src/commands/manage.rs b/crates/cli/src/commands/manage.rs index 08551c101..e7d15c8c2 100644 --- a/crates/cli/src/commands/manage.rs +++ b/crates/cli/src/commands/manage.rs @@ -207,7 +207,6 @@ enum Subcommand { } impl Options { - #[allow(clippy::too_many_lines)] pub async fn run(self, figment: &Figment) -> anyhow::Result { use Subcommand as SC; let clock = SystemClock::default(); diff --git a/crates/cli/src/commands/server.rs b/crates/cli/src/commands/server.rs index e7c5b0bc8..891400176 100644 --- a/crates/cli/src/commands/server.rs +++ b/crates/cli/src/commands/server.rs @@ -55,7 +55,6 @@ pub(super) struct Options { } impl Options { - #[allow(clippy::too_many_lines)] pub async fn run(self, figment: &Figment) -> anyhow::Result { let span = info_span!("cli.run.init").entered(); let mut shutdown = LifecycleManager::new()?; diff --git a/crates/cli/src/commands/syn2mas.rs b/crates/cli/src/commands/syn2mas.rs index fa768bf9d..50dd99778 100644 --- a/crates/cli/src/commands/syn2mas.rs +++ b/crates/cli/src/commands/syn2mas.rs @@ -88,7 +88,6 @@ const NUM_WRITER_CONNECTIONS: usize = 8; impl Options { #[tracing::instrument("cli.syn2mas.run", skip_all)] - #[allow(clippy::too_many_lines)] pub async fn run(self, figment: &Figment) -> anyhow::Result { if self.synapse_configuration_files.is_empty() { error!("Please specify the path to the Synapse configuration file(s)."); diff --git a/crates/cli/src/server.rs b/crates/cli/src/server.rs index ec3c2ddd7..9ce9b3a52 100644 --- a/crates/cli/src/server.rs +++ b/crates/cli/src/server.rs @@ -205,7 +205,6 @@ async fn log_response_middleware( response } -#[allow(clippy::too_many_lines)] pub fn build_router( state: AppState, resources: &[HttpResource], diff --git a/crates/cli/src/telemetry/tokio.rs b/crates/cli/src/telemetry/tokio.rs index 921582ee3..7346a7620 100644 --- a/crates/cli/src/telemetry/tokio.rs +++ b/crates/cli/src/telemetry/tokio.rs @@ -9,7 +9,6 @@ use tokio::runtime::RuntimeMetrics; use super::METER; /// Install metrics for the tokio runtime. -#[allow(clippy::too_many_lines)] pub fn observe(metrics: RuntimeMetrics) { { let metrics = metrics.clone(); diff --git a/crates/config/src/sections/secrets.rs b/crates/config/src/sections/secrets.rs index 47d898e6d..7886e9a57 100644 --- a/crates/config/src/sections/secrets.rs +++ b/crates/config/src/sections/secrets.rs @@ -303,6 +303,7 @@ impl ConfigurationSection for SecretsConfig { } impl SecretsConfig { + #[expect(clippy::similar_names, reason = "Key type names are very similar")] #[tracing::instrument(skip_all)] pub(crate) async fn generate(mut rng: R) -> anyhow::Result where diff --git a/crates/handlers/src/admin/v1/mod.rs b/crates/handlers/src/admin/v1/mod.rs index af1951019..1d167e98a 100644 --- a/crates/handlers/src/admin/v1/mod.rs +++ b/crates/handlers/src/admin/v1/mod.rs @@ -27,7 +27,6 @@ mod user_registration_tokens; mod user_sessions; mod users; -#[allow(clippy::too_many_lines)] pub fn router() -> ApiRouter where S: Clone + Send + Sync + 'static, diff --git a/crates/handlers/src/lib.rs b/crates/handlers/src/lib.rs index 7a55bcbe7..08367bbf5 100644 --- a/crates/handlers/src/lib.rs +++ b/crates/handlers/src/lib.rs @@ -328,7 +328,6 @@ where Router::new().merge(human_router).merge(api_router) } -#[allow(clippy::too_many_lines)] pub fn human_router(templates: Templates) -> Router where S: Clone + Send + Sync + 'static, diff --git a/crates/handlers/src/oauth2/authorization/mod.rs b/crates/handlers/src/oauth2/authorization/mod.rs index 339dc0408..6dfaf4020 100644 --- a/crates/handlers/src/oauth2/authorization/mod.rs +++ b/crates/handlers/src/oauth2/authorization/mod.rs @@ -109,7 +109,6 @@ fn resolve_response_mode( fields(client.id = %params.auth.client_id), skip_all, )] -#[allow(clippy::too_many_lines)] pub(crate) async fn get( mut rng: BoxRng, clock: BoxClock, diff --git a/crates/handlers/src/oauth2/discovery.rs b/crates/handlers/src/oauth2/discovery.rs index b1e2000a5..61dfc1ba5 100644 --- a/crates/handlers/src/oauth2/discovery.rs +++ b/crates/handlers/src/oauth2/discovery.rs @@ -35,7 +35,6 @@ struct DiscoveryResponse { } #[tracing::instrument(name = "handlers.oauth2.discovery.get", skip_all)] -#[allow(clippy::too_many_lines)] pub(crate) async fn get( State(key_store): State, State(url_builder): State, diff --git a/crates/handlers/src/oauth2/introspection.rs b/crates/handlers/src/oauth2/introspection.rs index f2f225475..508596d83 100644 --- a/crates/handlers/src/oauth2/introspection.rs +++ b/crates/handlers/src/oauth2/introspection.rs @@ -215,7 +215,6 @@ const SYNAPSE_ADMIN_SCOPE: ScopeToken = ScopeToken::from_static("urn:synapse:adm fields(client.id = credentials.client_id()), skip_all, )] -#[allow(clippy::too_many_lines)] pub(crate) async fn post( clock: BoxClock, State(http_client): State, diff --git a/crates/handlers/src/oauth2/token.rs b/crates/handlers/src/oauth2/token.rs index 768f79d35..4b4c8dca6 100644 --- a/crates/handlers/src/oauth2/token.rs +++ b/crates/handlers/src/oauth2/token.rs @@ -409,7 +409,6 @@ pub(crate) async fn post( Ok((headers, Json(reply))) } -#[allow(clippy::too_many_lines)] // TODO: refactor some parts out async fn authorization_code_grant( mut rng: &mut BoxRng, clock: &impl Clock, @@ -602,7 +601,6 @@ async fn authorization_code_grant( Ok((params, repo)) } -#[allow(clippy::too_many_lines)] async fn refresh_token_grant( rng: &mut BoxRng, clock: &impl Clock, diff --git a/crates/handlers/src/passwords.rs b/crates/handlers/src/passwords.rs index a6f4e8823..6f32f77f9 100644 --- a/crates/handlers/src/passwords.rs +++ b/crates/handlers/src/passwords.rs @@ -625,7 +625,6 @@ mod tests { ); } - #[allow(clippy::too_many_lines)] #[tokio::test] async fn hash_verify_and_upgrade() { // Tests the whole password manager, by hashing a password and upgrading it diff --git a/crates/handlers/src/upstream_oauth2/cache.rs b/crates/handlers/src/upstream_oauth2/cache.rs index 79a9fe5fb..cfee7b78e 100644 --- a/crates/handlers/src/upstream_oauth2/cache.rs +++ b/crates/handlers/src/upstream_oauth2/cache.rs @@ -165,6 +165,10 @@ impl MetadataCache { /// /// This spawns a background task that will refresh the cache at the given /// interval. + /// + /// # Errors + /// + /// Returns an error if the warm up task could not be started. #[tracing::instrument(name = "metadata_cache.warm_up_and_run", skip_all)] pub async fn warm_up_and_run( &self, @@ -237,6 +241,10 @@ impl MetadataCache { } /// Get the metadata for the given issuer. + /// + /// # Errors + /// + /// Returns an error if the metadata could not be retrieved. #[tracing::instrument(name = "metadata_cache.get", fields(%issuer), skip_all)] pub async fn get( &self, @@ -290,8 +298,6 @@ impl MetadataCache { #[cfg(test)] mod tests { - #![allow(clippy::too_many_lines)] - // XXX: sadly, we can't test HTTPS requests with wiremock, so we can only test // 'insecure' discovery diff --git a/crates/handlers/src/upstream_oauth2/callback.rs b/crates/handlers/src/upstream_oauth2/callback.rs index f6ffe1e7a..de1c087f7 100644 --- a/crates/handlers/src/upstream_oauth2/callback.rs +++ b/crates/handlers/src/upstream_oauth2/callback.rs @@ -168,7 +168,7 @@ impl IntoResponse for RouteError { fields(upstream_oauth_provider.id = %provider_id), skip_all, )] -#[allow(clippy::too_many_lines, clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments)] pub(crate) async fn handler( mut rng: BoxRng, clock: BoxClock, diff --git a/crates/handlers/src/views/register/password.rs b/crates/handlers/src/views/register/password.rs index a94cecddc..b7c29eaa1 100644 --- a/crates/handlers/src/views/register/password.rs +++ b/crates/handlers/src/views/register/password.rs @@ -119,7 +119,7 @@ pub(crate) async fn get( } #[tracing::instrument(name = "handlers.views.password_register.post", skip_all)] -#[allow(clippy::too_many_lines, clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments)] pub(crate) async fn post( mut rng: BoxRng, clock: BoxClock, diff --git a/crates/i18n/src/sprintf/formatter.rs b/crates/i18n/src/sprintf/formatter.rs index 8f940c26e..29c71f6aa 100644 --- a/crates/i18n/src/sprintf/formatter.rs +++ b/crates/i18n/src/sprintf/formatter.rs @@ -226,7 +226,7 @@ fn to_precision(number: f64, mut placeholder: Placeholder) -> String { } } -#[allow(clippy::too_many_lines, clippy::match_same_arms)] +#[allow(clippy::match_same_arms)] fn format_value(value: &Value, placeholder: &Placeholder) -> Result { match (value, &placeholder.type_specifier) { (Value::Number(number), ts @ TypeSpecifier::BinaryNumber) => { diff --git a/crates/iana-codegen/src/generation.rs b/crates/iana-codegen/src/generation.rs index 28343ee4f..3ee792df1 100644 --- a/crates/iana-codegen/src/generation.rs +++ b/crates/iana-codegen/src/generation.rs @@ -169,7 +169,6 @@ pub fn json_schema_impl( "{}".to_owned() }} - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {{ let enums = vec!["#, section.key, section.key, diff --git a/crates/iana-codegen/src/main.rs b/crates/iana-codegen/src/main.rs index 0477f0a13..cf809a0a9 100644 --- a/crates/iana-codegen/src/main.rs +++ b/crates/iana-codegen/src/main.rs @@ -71,7 +71,6 @@ impl File { } impl Display for File { - #[allow(clippy::too_many_lines)] fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { writeln!( f, diff --git a/crates/iana/src/jose.rs b/crates/iana/src/jose.rs index a60b309af..666d6cd7f 100644 --- a/crates/iana/src/jose.rs +++ b/crates/iana/src/jose.rs @@ -148,7 +148,6 @@ impl schemars::JsonSchema for JsonWebSignatureAlg { "JsonWebSignatureAlg".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -537,7 +536,6 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg { "JsonWebEncryptionAlg".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -887,7 +885,6 @@ impl schemars::JsonSchema for JsonWebEncryptionEnc { "JsonWebEncryptionEnc".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -1043,7 +1040,6 @@ impl schemars::JsonSchema for JsonWebEncryptionCompressionAlgorithm { "JsonWebEncryptionCompressionAlgorithm".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -1149,7 +1145,6 @@ impl schemars::JsonSchema for JsonWebKeyType { "JsonWebKeyType".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -1294,7 +1289,6 @@ impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve { "JsonWebKeyEcEllipticCurve".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -1439,7 +1433,6 @@ impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve { "JsonWebKeyOkpEllipticCurve".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -1574,7 +1567,6 @@ impl schemars::JsonSchema for JsonWebKeyUse { "JsonWebKeyUse".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -1713,7 +1705,6 @@ impl schemars::JsonSchema for JsonWebKeyOperation { "JsonWebKeyOperation".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- diff --git a/crates/iana/src/oauth.rs b/crates/iana/src/oauth.rs index 5dfbf1fb7..3b65ce9f2 100644 --- a/crates/iana/src/oauth.rs +++ b/crates/iana/src/oauth.rs @@ -83,7 +83,6 @@ impl schemars::JsonSchema for OAuthAccessTokenType { "OAuthAccessTokenType".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -215,7 +214,6 @@ impl schemars::JsonSchema for OAuthAuthorizationEndpointResponseType { "OAuthAuthorizationEndpointResponseType".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -351,7 +349,6 @@ impl schemars::JsonSchema for OAuthTokenTypeHint { "OAuthTokenTypeHint".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -477,7 +474,6 @@ impl schemars::JsonSchema for OAuthClientAuthenticationMethod { "OAuthClientAuthenticationMethod".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- @@ -602,7 +598,6 @@ impl schemars::JsonSchema for PkceCodeChallengeMethod { "PkceCodeChallengeMethod".to_owned() } - #[allow(clippy::too_many_lines)] fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let enums = vec![ // --- diff --git a/crates/jose/src/jwk/mod.rs b/crates/jose/src/jwk/mod.rs index 27ac929e9..98d40fa7a 100644 --- a/crates/jose/src/jwk/mod.rs +++ b/crates/jose/src/jwk/mod.rs @@ -413,7 +413,6 @@ mod tests { assert_eq!(candidates.len(), 1); } - #[allow(clippy::too_many_lines)] #[test] fn load_keycloak_keys() { let jwks = serde_json::json!({ diff --git a/crates/listener/src/proxy_protocol/v1.rs b/crates/listener/src/proxy_protocol/v1.rs index c993d8b77..bb78aa654 100644 --- a/crates/listener/src/proxy_protocol/v1.rs +++ b/crates/listener/src/proxy_protocol/v1.rs @@ -52,7 +52,6 @@ impl ParseError { } impl ProxyProtocolV1Info { - #[allow(clippy::too_many_lines)] pub(super) fn parse(buf: &mut B) -> Result where B: Buf + AsRef<[u8]>, diff --git a/crates/listener/src/server.rs b/crates/listener/src/server.rs index 50775cfbb..026706a45 100644 --- a/crates/listener/src/server.rs +++ b/crates/listener/src/server.rs @@ -290,7 +290,6 @@ where } } -#[allow(clippy::too_many_lines)] pub async fn run_servers( listeners: impl IntoIterator>, soft_shutdown_token: CancellationToken, diff --git a/crates/oauth2-types/src/registration/mod.rs b/crates/oauth2-types/src/registration/mod.rs index 7ca0d93a3..fd1ab2a64 100644 --- a/crates/oauth2-types/src/registration/mod.rs +++ b/crates/oauth2-types/src/registration/mod.rs @@ -440,7 +440,6 @@ impl ClientMetadata { /// Will return `Err` if validation fails. /// /// [OpenID Connect Dynamic Client Registration Spec 1.0]: https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata - #[allow(clippy::too_many_lines)] pub fn validate(self) -> Result { let grant_types = self.grant_types(); let has_implicit = grant_types.contains(&GrantType::Implicit); @@ -994,7 +993,6 @@ mod tests { } #[test] - #[allow(clippy::too_many_lines)] fn validate_response_types() { let mut metadata = valid_client_metadata(); diff --git a/crates/oauth2-types/src/response_type.rs b/crates/oauth2-types/src/response_type.rs index 669036c28..1f3322e94 100644 --- a/crates/oauth2-types/src/response_type.rs +++ b/crates/oauth2-types/src/response_type.rs @@ -272,7 +272,6 @@ mod tests { } #[test] - #[allow(clippy::too_many_lines)] fn deserialize_response_type() { serde_json::from_str::("\"\"").unwrap_err(); diff --git a/crates/oidc-client/src/types/client_credentials.rs b/crates/oidc-client/src/types/client_credentials.rs index 6fe61f04e..a097ef469 100644 --- a/crates/oidc-client/src/types/client_credentials.rs +++ b/crates/oidc-client/src/types/client_credentials.rs @@ -130,7 +130,6 @@ impl ClientCredentials { /// Apply these [`ClientCredentials`] to the given request with the given /// form. - #[allow(clippy::too_many_lines)] pub(crate) fn authenticated_form( &self, request: reqwest::RequestBuilder, diff --git a/crates/policy/src/lib.rs b/crates/policy/src/lib.rs index 8b8ede25b..b45da09ac 100644 --- a/crates/policy/src/lib.rs +++ b/crates/policy/src/lib.rs @@ -197,6 +197,11 @@ pub struct PolicyFactory { } impl PolicyFactory { + /// Load the policy from the given data source. + /// + /// # Errors + /// + /// Returns an error if the policy can't be loaded or instantiated. #[tracing::instrument(name = "policy.load", skip(source))] pub async fn load( mut source: impl AsyncRead + std::marker::Unpin, @@ -283,6 +288,12 @@ impl PolicyFactory { Ok(true) } + /// Create a new policy instance. + /// + /// # Errors + /// + /// Returns an error if the policy can't be instantiated with the current + /// dynamic data. #[tracing::instrument(name = "policy.instantiate", skip_all)] pub async fn instantiate(&self) -> Result { let data = self.dynamic_data.load(); @@ -336,6 +347,11 @@ pub enum EvaluationError { } impl Policy { + /// Evaluate the 'email' entrypoint. + /// + /// # Errors + /// + /// Returns an error if the policy engine fails to evaluate the entrypoint. #[tracing::instrument( name = "policy.evaluate_email", skip_all, @@ -355,6 +371,11 @@ impl Policy { Ok(res) } + /// Evaluate the 'register' entrypoint. + /// + /// # Errors + /// + /// Returns an error if the policy engine fails to evaluate the entrypoint. #[tracing::instrument( name = "policy.evaluate.register", skip_all, @@ -376,6 +397,11 @@ impl Policy { Ok(res) } + /// Evaluate the 'client_registration' entrypoint. + /// + /// # Errors + /// + /// Returns an error if the policy engine fails to evaluate the entrypoint. #[tracing::instrument(skip(self))] pub async fn evaluate_client_registration( &mut self, @@ -393,6 +419,11 @@ impl Policy { Ok(res) } + /// Evaluate the 'authorization_grant' entrypoint. + /// + /// # Errors + /// + /// Returns an error if the policy engine fails to evaluate the entrypoint. #[tracing::instrument( name = "policy.evaluate.authorization_grant", skip_all, diff --git a/crates/storage-pg/src/app_session.rs b/crates/storage-pg/src/app_session.rs index d11cb01d6..6d881ecea 100644 --- a/crates/storage-pg/src/app_session.rs +++ b/crates/storage-pg/src/app_session.rs @@ -82,7 +82,6 @@ use priv_::{AppSessionLookup, AppSessionLookupIden}; impl TryFrom for AppSession { type Error = DatabaseError; - #[allow(clippy::too_many_lines)] fn try_from(value: AppSessionLookup) -> Result { // This is annoying to do, but we have to match on all the fields to determine // whether it's a compat session or an oauth2 session @@ -257,7 +256,6 @@ fn split_filter( impl AppSessionRepository for PgAppSessionRepository<'_> { type Error = DatabaseError; - #[allow(clippy::too_many_lines)] #[tracing::instrument( name = "db.app_session.list", fields( diff --git a/crates/storage-pg/src/oauth2/authorization_grant.rs b/crates/storage-pg/src/oauth2/authorization_grant.rs index f58cfa69b..d9727ead0 100644 --- a/crates/storage-pg/src/oauth2/authorization_grant.rs +++ b/crates/storage-pg/src/oauth2/authorization_grant.rs @@ -60,7 +60,6 @@ struct GrantLookup { impl TryFrom for AuthorizationGrant { type Error = DatabaseInconsistencyError; - #[allow(clippy::too_many_lines)] fn try_from(value: GrantLookup) -> Result { let id = value.oauth2_authorization_grant_id.into(); let scope: Scope = value.scope.parse().map_err(|e| { diff --git a/crates/storage-pg/src/oauth2/client.rs b/crates/storage-pg/src/oauth2/client.rs index 2bcd51fe5..2c76f484d 100644 --- a/crates/storage-pg/src/oauth2/client.rs +++ b/crates/storage-pg/src/oauth2/client.rs @@ -67,7 +67,6 @@ struct OAuth2ClientLookup { impl TryInto for OAuth2ClientLookup { type Error = DatabaseInconsistencyError; - #[allow(clippy::too_many_lines)] // TODO: refactor some of the field parsing fn try_into(self) -> Result { let id = Ulid::from(self.oauth2_client_id); @@ -416,7 +415,6 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> { ), err, )] - #[allow(clippy::too_many_lines)] async fn add( &mut self, rng: &mut (dyn RngCore + Send), diff --git a/crates/storage-pg/src/upstream_oauth2/provider.rs b/crates/storage-pg/src/upstream_oauth2/provider.rs index 4086e623c..364a81c90 100644 --- a/crates/storage-pg/src/upstream_oauth2/provider.rs +++ b/crates/storage-pg/src/upstream_oauth2/provider.rs @@ -77,7 +77,6 @@ struct ProviderLookup { impl TryFrom for UpstreamOAuthProvider { type Error = DatabaseInconsistencyError; - #[allow(clippy::too_many_lines)] fn try_from(value: ProviderLookup) -> Result { let id = value.upstream_oauth_provider_id.into(); let scope = value.scope.parse().map_err(|e| { diff --git a/crates/storage-pg/src/user/registration_token.rs b/crates/storage-pg/src/user/registration_token.rs index 1a8ed0ae7..b748c4645 100644 --- a/crates/storage-pg/src/user/registration_token.rs +++ b/crates/storage-pg/src/user/registration_token.rs @@ -54,7 +54,6 @@ struct UserRegistrationTokenLookup { } impl Filter for UserRegistrationTokenFilter { - #[expect(clippy::too_many_lines)] fn generate_condition(&self, _has_joins: bool) -> impl sea_query::IntoCondition { sea_query::Condition::all() .add_option(self.has_been_used().map(|has_been_used| { diff --git a/crates/syn2mas/src/synapse_reader/config/oidc.rs b/crates/syn2mas/src/synapse_reader/config/oidc.rs index c08023bf2..49ee59a71 100644 --- a/crates/syn2mas/src/synapse_reader/config/oidc.rs +++ b/crates/syn2mas/src/synapse_reader/config/oidc.rs @@ -193,7 +193,6 @@ impl OidcProvider { } /// Map this Synapse OIDC provider config to a MAS upstream provider config. - #[expect(clippy::too_many_lines)] pub(crate) fn into_mas_config( self, rng: &mut impl Rng, diff --git a/crates/tasks/src/new_queue.rs b/crates/tasks/src/new_queue.rs index 60731ea72..06f358f31 100644 --- a/crates/tasks/src/new_queue.rs +++ b/crates/tasks/src/new_queue.rs @@ -639,7 +639,7 @@ impl QueueWorker { let now = clock.now(); for schedule in &self.schedules { // Find the schedule status from the database - let Some(schedule_status) = schedules_status + let Some(status) = schedules_status .iter() .find(|s| s.schedule_name == schedule.schedule_name) else { @@ -651,13 +651,13 @@ impl QueueWorker { }; // Figure out if we should schedule a new job - if let Some(next_time) = schedule_status.last_scheduled_at { + if let Some(next_time) = status.last_scheduled_at { if next_time > now { // We already have a job scheduled in the future, skip continue; } - if schedule_status.last_scheduled_job_completed == Some(false) { + if status.last_scheduled_job_completed == Some(false) { // The last scheduled job has not completed yet, skip continue; } @@ -960,7 +960,6 @@ impl JobTracker { /// If `blocking` is `true`, this function will block until all the jobs /// are finished. Otherwise, it will return as soon as it processed the /// already finished jobs. - #[allow(clippy::too_many_lines)] async fn process_jobs( &mut self, rng: &mut (dyn RngCore + Send), diff --git a/crates/templates/src/lib.rs b/crates/templates/src/lib.rs index cebe1fdd7..d588e12ea 100644 --- a/crates/templates/src/lib.rs +++ b/crates/templates/src/lib.rs @@ -135,6 +135,10 @@ fn is_hidden(entry: &DirEntry) -> bool { impl Templates { /// Load the templates from the given config + /// + /// # Errors + /// + /// Returns an error if the templates could not be loaded from disk. #[tracing::instrument( name = "templates.load", skip_all, @@ -254,6 +258,10 @@ impl Templates { } /// Reload the templates on disk + /// + /// # Errors + /// + /// Returns an error if the templates could not be reloaded from disk. #[tracing::instrument( name = "templates.reload", skip_all,