Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: address Rust 1.80 clippy lints #5447

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions crates/api_models/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,6 @@ impl_api_event_type!(
)
);

#[cfg(feature = "stripe")]
impl_api_event_type!(
Miscellaneous,
(
StripeSetupIntentResponse,
StripeRefundResponse,
StripePaymentIntentListResponse,
StripePaymentIntentResponse,
CustomerDeleteResponse,
CustomerPaymentMethodListResponse,
CreateCustomerResponse
)
);

impl<T> ApiEventMetric for MetricsResponse<T> {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Miscellaneous)
Expand Down
3 changes: 0 additions & 3 deletions crates/external_services/src/file_storage/file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ use crate::file_storage::{FileStorageError, FileStorageInterface};
/// The file path is generated based on the workspace path and the provided file key.
fn get_file_path(file_key: impl AsRef<str>) -> PathBuf {
let mut file_path = PathBuf::new();
#[cfg(feature = "logs")]
file_path.push(router_env::env::workspace_path());
#[cfg(not(feature = "logs"))]
file_path.push(std::env::current_dir().unwrap_or(".".into()));

file_path.push("files");
Expand Down
8 changes: 4 additions & 4 deletions crates/router/src/compatibility/stripe/payment_intents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn payment_intents_create(
Err(err) => return api::log_and_return_error_response(err),
};

tracing::Span::current().record("payment_id", &payload.id.clone().unwrap_or_default());
tracing::Span::current().record("payment_id", payload.id.clone().unwrap_or_default());

logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?payload);

Expand Down Expand Up @@ -170,7 +170,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds(
_ => Flow::PaymentsRetrieve,
};

tracing::Span::current().record("flow", &flow.to_string());
tracing::Span::current().record("flow", flow.to_string());

let locking_action = payload.get_locking_input(flow.clone());
Box::pin(wrap::compatibility_api_wrap::<
Expand Down Expand Up @@ -361,7 +361,7 @@ pub async fn payment_intents_capture(
}
};

tracing::Span::current().record("payment_id", &stripe_payload.payment_id.clone());
tracing::Span::current().record("payment_id", stripe_payload.payment_id.clone());

logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?stripe_payload);

Expand Down Expand Up @@ -423,7 +423,7 @@ pub async fn payment_intents_cancel(
}
};

tracing::Span::current().record("payment_id", &payment_id.clone());
tracing::Span::current().record("payment_id", payment_id.clone());

logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?stripe_payload);

Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/compatibility/stripe/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn refund_create(
Err(err) => return api::log_and_return_error_response(err),
};

tracing::Span::current().record("payment_id", &payload.payment_intent.clone());
tracing::Span::current().record("payment_id", payload.payment_intent.clone());

logger::info!(tag = ?Tag::CompatibilityLayerRequest, payload = ?payload);

Expand Down Expand Up @@ -76,7 +76,7 @@ pub async fn refund_retrieve_with_gateway_creds(
_ => Flow::RefundsRetrieve,
};

tracing::Span::current().record("flow", &flow.to_string());
tracing::Span::current().record("flow", flow.to_string());

Box::pin(wrap::compatibility_api_wrap::<
_,
Expand Down
10 changes: 0 additions & 10 deletions crates/router/src/configs/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ pub struct CmdLineConf {
/// Application will look for "config/config.toml" if this option isn't specified.
#[arg(short = 'f', long, value_name = "FILE")]
pub config_path: Option<PathBuf>,

#[command(subcommand)]
pub subcommand: Option<Subcommand>,
}

#[derive(clap::Parser)]
pub enum Subcommand {
#[cfg(feature = "openapi")]
/// Generate the OpenAPI specification file from code.
GenerateOpenapiSpec,
}

#[derive(Debug, Deserialize, Clone, Default)]
Expand Down
12 changes: 0 additions & 12 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,12 +688,6 @@ pub struct MbwayData {
telephone_number: Secret<String>,
}

#[derive(Debug, Clone, Serialize)]
pub struct WalleyData {
#[serde(rename = "type")]
payment_type: PaymentType,
}

#[derive(Debug, Clone, Serialize)]
pub struct SamsungPayPmData {
#[serde(rename = "type")]
Expand All @@ -702,12 +696,6 @@ pub struct SamsungPayPmData {
samsung_pay_token: Secret<String>,
}

#[derive(Debug, Clone, Serialize)]
pub struct PayBrightData {
#[serde(rename = "type")]
payment_type: PaymentType,
}

#[derive(Debug, Clone, Serialize)]
pub struct OnlineBankingCzechRepublicData {
#[serde(rename = "type")]
Expand Down
6 changes: 0 additions & 6 deletions crates/router/src/connector/bluesnap/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ pub struct BluesnapGooglePayObject {
payment_method_data: utils::GooglePayWalletData,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BluesnapApplePayObject {
token: payments::ApplePayWalletData,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum BluesnapWalletTypes {
Expand Down
5 changes: 0 additions & 5 deletions crates/router/src/connector/boku/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,6 @@ pub struct BokuErrorResponse {
pub reason: Option<String>,
}

#[derive(Debug, Serialize)]
pub struct BokuConnMetaData {
country: String,
}

fn get_hosted_data(item: &types::PaymentsAuthorizeRouterData) -> Option<BokuHostedData> {
item.return_url
.clone()
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/globalpay/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ pub struct PaymentMethod {
/// If enabled, this field indicates whether the payment method has been seen before or is
/// new.
/// * EXISTS - Indicates that the payment method was seen on the platform before by this
/// merchant.
/// merchant.
/// * NEW - Indicates that the payment method was not seen on the platform before by this
/// merchant.
/// merchant.
pub fingerprint_presence_indicator: Option<String>,
/// Unique Global Payments generated id used to reference a stored payment method on the
/// Global Payments system. Often referred to as the payment method token. This value can be
Expand Down
6 changes: 0 additions & 6 deletions crates/router/src/connector/mollie/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,6 @@ pub struct CardDetails {
pub card_cvv: Secret<String>,
}

#[derive(Debug, Serialize, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct BankDetails {
billing_email: Email,
}

pub struct MollieAuthType {
pub(super) api_key: Secret<String>,
pub(super) profile_token: Option<Secret<String>>,
Expand Down
16 changes: 8 additions & 8 deletions crates/router/src/connector/netcetera/netcetera_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct ThreeDSRequestor {
/// Format of this field was changed with EMV 3DS 2.3.1 version:
/// In versions prior to 2.3.1, this field is a single object.
/// Starting from EMVCo version 2.3.1, this field is now an array of objects. Accepted value length is 1-3 elements.
///
///
/// This field is optional, but recommended to include.
#[serde(rename = "threeDSRequestorAuthenticationInfo")]
pub three_ds_requestor_authentication_info:
Expand Down Expand Up @@ -206,26 +206,26 @@ pub struct ThreeDSRequestorAuthenticationInformation {
/// Indicates whether a challenge is requested for this transaction. For example: For 01-PA, a 3DS Requestor may have
/// concerns about the transaction, and request a challenge. For 02-NPA, a challenge may be necessary when adding a new
/// card to a wallet.
///
///
/// This field is optional. The accepted values are:
///
/// - 01 -> No preference
/// - 02 -> No challenge requested
/// - 03 -> Challenge requested: 3DS Requestor Preference
/// - 04 -> Challenge requested: Mandate.
/// The next values are accepted as well if 3DS Server initiates authentication with EMV 3DS 2.2.0 version
/// or greater (required protocol version can be set in
/// ThreeDSServerAuthenticationRequest#preferredProtocolVersion field):
/// The next values are accepted as well if 3DS Server initiates authentication with EMV 3DS 2.2.0 version
/// or greater (required protocol version can be set in
/// ThreeDSServerAuthenticationRequest#preferredProtocolVersion field):
///
/// - 05 -> No challenge requested (transactional risk analysis is already performed)
/// - 06 -> No challenge requested (Data share only)
/// - 07 -> No challenge requested (strong consumer authentication is already performed)
/// - 08 -> No challenge requested (utilise whitelist exemption if no challenge required)
/// - 09 -> Challenge requested (whitelist prompt requested if challenge required).
/// - Additionally, 80-99 can be used for PS-specific values, regardless of protocol version.
///
///
/// If the element is not provided, the expected action is that the ACS would interpret as 01 -> No preference.
///
///
/// Format of this field was changed with EMV 3DS 2.3.1 version:
/// In versions prior to 2.3.1, this field is a String.
/// Starting from EMVCo version 2.3.1, this field is now an array of objects. Accepted value length is 1-2 elements.
Expand Down Expand Up @@ -257,7 +257,7 @@ pub enum ThreeDSRequestorChallengeIndicator {
/// Format of this field was changed with EMV 3DS 2.3.1 version:
/// In versions prior to 2.3.1, this field is a single object.
/// Starting from EMVCo version 2.3.1, this field is now an array of objects. Accepted value length is 1-3 elements.
///
///
/// This field is optional, but recommended to include for versions prior to 2.3.1. From 2.3.1,
/// it is required for 3RI in the case of Decoupled Authentication Fallback or for SPC.
#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
30 changes: 15 additions & 15 deletions crates/router/src/connector/powertranz/transformers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common_utils::pii::{Email, IpAddress};
use common_utils::pii::IpAddress;
use diesel_models::enums::RefundStatus;
use masking::{ExposeInterface, Secret};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -74,20 +74,20 @@ pub struct PowertranzCard {
card_cvv: Secret<String>,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct PowertranzAddressDetails {
first_name: Option<Secret<String>>,
last_name: Option<Secret<String>>,
line1: Option<Secret<String>>,
line2: Option<Secret<String>>,
city: Option<String>,
country: Option<enums::CountryAlpha2>,
state: Option<Secret<String>>,
postal_code: Option<Secret<String>>,
email_address: Option<Email>,
phone_number: Option<Secret<String>>,
}
// #[derive(Debug, Serialize)]
// #[serde(rename_all = "PascalCase")]
// pub struct PowertranzAddressDetails {
// first_name: Option<Secret<String>>,
// last_name: Option<Secret<String>>,
// line1: Option<Secret<String>>,
// line2: Option<Secret<String>>,
// city: Option<String>,
// country: Option<enums::CountryAlpha2>,
// state: Option<Secret<String>>,
// postal_code: Option<Secret<String>>,
// email_address: Option<Email>,
// phone_number: Option<Secret<String>>,
// }

#[derive(Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
Expand Down
53 changes: 0 additions & 53 deletions crates/router/src/db/user_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,56 +634,3 @@ impl UserRoleInterface for MockDb {
Ok(filtered_roles)
}
}

#[cfg(feature = "kafka_events")]
#[async_trait::async_trait]
impl UserRoleInterface for super::KafkaStore {
async fn insert_user_role(
&self,
user_role: storage::UserRoleNew,
) -> CustomResult<storage::UserRole, errors::StorageError> {
self.diesel_store.insert_user_role(user_role).await
}
async fn update_user_role_by_user_id_merchant_id(
&self,
user_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
update: storage::UserRoleUpdate,
) -> CustomResult<storage::UserRole, errors::StorageError> {
self.diesel_store
.update_user_role_by_user_id_merchant_id(user_id, merchant_id, update)
.await
}
async fn find_user_role_by_user_id(
&self,
user_id: &str,
version: enums::UserRoleVersion,
) -> CustomResult<storage::UserRole, errors::StorageError> {
self.diesel_store
.find_user_role_by_user_id(user_id, version)
.await
}
async fn delete_user_role_by_user_id_merchant_id(
&self,
user_id: &str,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<storage::UserRole, errors::StorageError> {
self.diesel_store
.delete_user_role_by_user_id_merchant_id(user_id, merchant_id)
.await
}
async fn list_user_roles_by_user_id(
&self,
user_id: &str,
) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {
self.diesel_store.list_user_roles_by_user_id(user_id).await
}
async fn list_user_roles_by_merchant_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<storage::UserRole>, errors::StorageError> {
self.diesel_store
.list_user_roles_by_merchant_id(merchant_id)
.await
}
}
8 changes: 4 additions & 4 deletions crates/router/src/routes/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub async fn payments_create(

tracing::Span::current().record(
"payment_id",
&payload
payload
.payment_id
.as_ref()
.map(|payment_id_type| payment_id_type.get_payment_intent_id())
Expand Down Expand Up @@ -254,8 +254,8 @@ pub async fn payments_retrieve(
..Default::default()
};

tracing::Span::current().record("payment_id", &path.to_string());
tracing::Span::current().record("flow", &flow.to_string());
tracing::Span::current().record("payment_id", path.to_string());
tracing::Span::current().record("flow", flow.to_string());

let (auth_type, auth_flow) =
match auth::check_client_secret_and_get_auth(req.headers(), &payload) {
Expand Down Expand Up @@ -334,7 +334,7 @@ pub async fn payments_retrieve_with_gateway_creds(
};

tracing::Span::current().record("payment_id", &json_payload.payment_id);
tracing::Span::current().record("flow", &flow.to_string());
tracing::Span::current().record("flow", flow.to_string());

let locking_action = payload.get_locking_input(flow.clone());

Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/routes/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub async fn refunds_retrieve(
_ => Flow::RefundsRetrieve,
};

tracing::Span::current().record("flow", &flow.to_string());
tracing::Span::current().record("flow", flow.to_string());

Box::pin(api::server_wrap(
flow,
Expand Down Expand Up @@ -132,7 +132,7 @@ pub async fn refunds_retrieve_with_body(
_ => Flow::RefundsRetrieve,
};

tracing::Span::current().record("flow", &flow.to_string());
tracing::Span::current().record("flow", flow.to_string());

Box::pin(api::server_wrap(
flow,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/services/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ where
// If needed add an error stack as follows
// connector_integration.build_request(req).attach_printable("Failed to build request");
tracing::Span::current().record("connector_name", &req.connector);
tracing::Span::current().record("payment_method", &req.payment_method.to_string());
tracing::Span::current().record("payment_method", req.payment_method.to_string());
logger::debug!(connector_request=?connector_request);
let mut router_data = req.clone();
match call_connector_action {
Expand Down
Loading
Loading