Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Fix recently added Clippy lints
Browse files Browse the repository at this point in the history
This also ignores the clippy::blocks_in_conditions lint in two crates,
until tracing gets fixed: tokio-rs/tracing#2876
  • Loading branch information
sandhose committed May 7, 2024
1 parent 3ea24dc commit 3978acd
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 57 deletions.
2 changes: 1 addition & 1 deletion crates/cli/src/commands/manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ impl Options {
})
.await??;

req.upstream_provider_mappings.push((&provider, subject));
req.upstream_provider_mappings.push((provider, subject));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/config/src/sections/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum EmailSmtpMode {
/// Plain text
Plain,

/// StartTLS (starts as plain text then upgrade to TLS)
/// `StartTLS` (starts as plain text then upgrade to TLS)
StartTls,

/// TLS
Expand Down Expand Up @@ -94,7 +94,7 @@ pub struct EmailConfig {
hostname: Option<String>,

/// SMTP transport: Port to connect to. Default is 25 for plain, 465 for TLS
/// and 587 for StartTLS
/// and 587 for `StartTLS`
#[serde(skip_serializing_if = "Option::is_none")]
#[schemars(range(min = 1, max = 65535))]
port: Option<NonZeroU16>,
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/sections/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub struct ListenerConfig {
/// List of sockets to bind
pub binds: Vec<BindConfig>,

/// Accept HAProxy's Proxy Protocol V1
/// Accept `HAProxy`'s Proxy Protocol V1
#[serde(default)]
pub proxy_protocol: bool,

Expand Down
8 changes: 4 additions & 4 deletions crates/data-model/src/oauth2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Client {
/// Array of Redirection URI values used by the Client
pub redirect_uris: Vec<Url>,

/// Array containing a list of the OAuth 2.0 response_type values that the
/// Array containing a list of the OAuth 2.0 `response_type` values that the
/// Client is declaring that it will restrict itself to using
pub response_types: Vec<OAuthAuthorizationEndpointResponseType>,

Expand Down Expand Up @@ -83,15 +83,15 @@ pub struct Client {
/// Client
pub id_token_signed_response_alg: Option<JsonWebSignatureAlg>,

/// JWS alg algorithm REQUIRED for signing UserInfo Responses.
/// JWS alg algorithm REQUIRED for signing `UserInfo` Responses.
pub userinfo_signed_response_alg: Option<JsonWebSignatureAlg>,

/// Requested authentication method for the token endpoint
pub token_endpoint_auth_method: Option<OAuthClientAuthenticationMethod>,

/// JWS alg algorithm that MUST be used for signing the JWT used to
/// authenticate the Client at the Token Endpoint for the private_key_jwt
/// and client_secret_jwt authentication methods
/// authenticate the Client at the Token Endpoint for the `private_key_jwt`
/// and `client_secret_jwt` authentication methods
pub token_endpoint_auth_signing_alg: Option<JsonWebSignatureAlg>,

/// URI using the https scheme that a third party can use to initiate a
Expand Down
9 changes: 2 additions & 7 deletions crates/data-model/src/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ impl UserAgent {
result.os_version = VALUE_UNKNOWN.into();
}

// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like
// Gecko) Chrome/100.0.4896.133 Safari/537.36
("Mac OSX", "10.15.7") if user_agent.contains("Macintosh; Intel Mac OS X 10_15_7") => {
result.os = "macOS";
result.os_version = VALUE_UNKNOWN.into();
}

// Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
// Chrome/100.0.0.0 Safari/537.36
("Linux", _) if user_agent.contains("X11; Linux x86_64") => {
Expand All @@ -176,6 +169,8 @@ impl UserAgent {
result.os_version = VALUE_UNKNOWN.into();
}

// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like
// Gecko) Chrome/100.0.4896.133 Safari/537.36
// Safari also freezes the OS version
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like
// Gecko) Version/17.3.1 Safari/605.1.15
Expand Down
2 changes: 1 addition & 1 deletion crates/email/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use thiserror::Error;
pub enum SmtpMode {
/// Plain text
Plain,
/// StartTLS (starts as plain text then upgrade to TLS)
/// `StartTLS` (starts as plain text then upgrade to TLS)
StartTls,
/// TLS
Tls,
Expand Down
2 changes: 1 addition & 1 deletion crates/graphql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub enum Requester {
/// The requester is a browser session, stored in a cookie.
BrowserSession(Box<BrowserSession>),

/// The requester is a OAuth2 session, with an access token.
/// The requester is a `OAuth2` session, with an access token.
OAuth2Session(Box<(Session, Option<User>)>),
}

Expand Down
22 changes: 1 addition & 21 deletions crates/handlers/src/oauth2/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use axum::{extract::State, response::IntoResponse, Json, TypedHeader};
use chrono::{DateTime, Duration, Utc};
use chrono::Duration;
use headers::{CacheControl, HeaderMap, HeaderMapExt, Pragma};
use hyper::StatusCode;
use mas_axum_utils::{
Expand Down Expand Up @@ -46,33 +46,13 @@ use oauth2_types::{
},
scope,
};
use serde::Serialize;
use serde_with::{serde_as, skip_serializing_none};
use thiserror::Error;
use tracing::debug;
use ulid::Ulid;
use url::Url;

use super::{generate_id_token, generate_token_pair};
use crate::{impl_from_error_for_route, BoundActivityTracker};

#[serde_as]
#[skip_serializing_none]
#[derive(Serialize, Debug)]
struct CustomClaims {
#[serde(rename = "iss")]
issuer: Url,
#[serde(rename = "sub")]
subject: String,
#[serde(rename = "aud")]
audiences: Vec<String>,
nonce: Option<String>,
#[serde_as(as = "Option<serde_with::TimestampSeconds>")]
auth_time: Option<DateTime<Utc>>,
at_hash: String,
c_hash: String,
}

#[derive(Debug, Error)]
pub(crate) enum RouteError {
#[error(transparent)]
Expand Down
5 changes: 1 addition & 4 deletions crates/handlers/src/passwords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ impl PasswordManager {
///
/// Returns an error if the password manager is disabled
fn get_inner(&self) -> Result<Arc<InnerPasswordManager>, PasswordManagerDisabledError> {
self.inner
.as_ref()
.map(Arc::clone)
.ok_or(PasswordManagerDisabledError)
self.inner.clone().ok_or(PasswordManagerDisabledError)
}

/// Hash a password with the default hashing scheme.
Expand Down
2 changes: 1 addition & 1 deletion crates/handlers/src/upstream_oauth2/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub(crate) enum RouteError {
#[error("Template {template:?} rendered to an empty string")]
RequiredAttributeEmpty { template: String },

/// Required claim was missing in id_token
/// Required claim was missing in `id_token`
#[error("Template {template:?} could not be rendered from the upstream provider's response for required claim")]
RequiredAttributeRender {
template: String,
Expand Down
5 changes: 1 addition & 4 deletions crates/i18n/src/translations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,7 @@ impl Tree {
path: I,
) -> Option<&Node> {
let mut iterator = path.into_iter();
let Some(next) = iterator.next() else {
return None;
};

let next = iterator.next()?;
self.walk_path_inner(next, iterator)
}

Expand Down
2 changes: 2 additions & 0 deletions crates/iana-codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ impl Display for File {
// See the License for the specific language governing permissions and
// limitations under the License.
#![allow(clippy::doc_markdown)]
//! Enums from the {:?} IANA registry
//! See <{}>
Expand Down
2 changes: 2 additions & 0 deletions crates/iana/src/jose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![allow(clippy::doc_markdown)]

//! Enums from the "JSON Object Signing and Encryption" IANA registry
//! See <https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml>
Expand Down
2 changes: 2 additions & 0 deletions crates/iana/src/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![allow(clippy::doc_markdown)]

//! Enums from the "OAuth Parameters" IANA registry
//! See <https://www.iana.org/assignments/jose/jose.xhtml>
Expand Down
2 changes: 1 addition & 1 deletion crates/listener/src/proxy_protocol/acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use tokio::io::{AsyncRead, AsyncReadExt};
use super::ProxyProtocolV1Info;
use crate::rewind::Rewind;

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Default)]
pub struct ProxyAcceptor {
_private: (),
}
Expand Down
2 changes: 2 additions & 0 deletions crates/matrix-synapse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![allow(clippy::blocks_in_conditions)]

use http::{header::AUTHORIZATION, request::Builder, Method, Request, StatusCode};
use mas_axum_utils::http_client_factory::HttpClientFactory;
use mas_http::{EmptyBody, HttpServiceExt};
Expand Down
2 changes: 1 addition & 1 deletion crates/oidc-client/src/types/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub enum ScopeToken {
/// `offline_access`
///
/// Requests that an OAuth 2.0 refresh token be issued that can be used to
/// obtain an access token that grants access to the end-user's UserInfo
/// obtain an access token that grants access to the end-user's `UserInfo`
/// Endpoint even when the end-user is not present (not logged in).
OfflineAccess,

Expand Down
2 changes: 1 addition & 1 deletion crates/storage-pg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
//! [`Uuid`]: uuid::Uuid
#![deny(clippy::future_not_send, missing_docs)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::module_name_repetitions, clippy::blocks_in_conditions)]

use sqlx::migrate::Migrator;

Expand Down
5 changes: 1 addition & 4 deletions crates/tasks/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ impl<J: Job> TracedJob for JobWithSpanContext<J> {
}
}

fn make_span_for_job_request<J: TracedJob>(req: &JobRequest<J>) -> tracing::Span
where
J: Job,
{
fn make_span_for_job_request<J: TracedJob>(req: &JobRequest<J>) -> tracing::Span {
let span = info_span!(
"job.run",
"otel.kind" = "consumer",
Expand Down
6 changes: 3 additions & 3 deletions docs/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
}
},
"proxy_protocol": {
"description": "Accept HAProxy's Proxy Protocol V1",
"description": "Accept `HAProxy`'s Proxy Protocol V1",
"default": false,
"type": "boolean"
},
Expand Down Expand Up @@ -1279,7 +1279,7 @@
]
},
"port": {
"description": "SMTP transport: Port to connect to. Default is 25 for plain, 465 for TLS and 587 for StartTLS",
"description": "SMTP transport: Port to connect to. Default is 25 for plain, 465 for TLS and 587 for `StartTLS`",
"type": "integer",
"format": "uint16",
"maximum": 65535.0,
Expand Down Expand Up @@ -1337,7 +1337,7 @@
]
},
{
"description": "StartTLS (starts as plain text then upgrade to TLS)",
"description": "`StartTLS` (starts as plain text then upgrade to TLS)",
"type": "string",
"enum": [
"starttls"
Expand Down

0 comments on commit 3978acd

Please sign in to comment.