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.84.0 clippy lints #7021

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 10 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions crates/diesel_models/src/query/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ impl AddressNew {
}

impl Address {
pub async fn find_by_address_id<'a>(
conn: &PgPooledConn,
address_id: &str,
) -> StorageResult<Self> {
pub async fn find_by_address_id(conn: &PgPooledConn, address_id: &str) -> StorageResult<Self> {
generics::generic_find_by_id::<<Self as HasTable>::Table, _, _>(conn, address_id.to_owned())
.await
}
Expand Down Expand Up @@ -104,7 +101,7 @@ impl Address {
.await
}

pub async fn find_by_merchant_id_payment_id_address_id<'a>(
pub async fn find_by_merchant_id_payment_id_address_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
payment_id: &common_utils::id_type::PaymentId,
Expand Down Expand Up @@ -133,7 +130,7 @@ impl Address {
}
}

pub async fn find_optional_by_address_id<'a>(
pub async fn find_optional_by_address_id(
conn: &PgPooledConn,
address_id: &str,
) -> StorageResult<Option<Self>> {
Expand Down
3 changes: 1 addition & 2 deletions crates/euclid/src/backend/vir_interpreter/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ impl Context {
.get(&key)
.and_then(|value| value.get_num_value());

value.get_num_value().zip(ctx_num_value).map_or(
false,
value.get_num_value().zip(ctx_num_value).is_some_and(
|(program_value, ctx_value)| {
let program_num = program_value.number;
let ctx_num = ctx_value.number;
Expand Down
4 changes: 2 additions & 2 deletions crates/euclid/src/dssa/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ impl cgraph::CheckingContext for AnalysisContext {
DataType::EnumVariant | DataType::StrValue | DataType::MetadataValue => {
value_set.contains(val)
}
DataType::Number => val.get_num_value().map_or(false, |num_val| {
DataType::Number => val.get_num_value().is_some_and(|num_val| {
value_set.iter().any(|ctx_val| {
ctx_val
.get_num_value()
.map_or(false, |ctx_num_val| num_val.fits(&ctx_num_val))
.is_some_and(|ctx_num_val| num_val.fits(&ctx_num_val))
})
}),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/euclid_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ron-parser = "0.1.4"
serde = { version = "1.0", features = [] }
serde-wasm-bindgen = "0.6.5"
strum = { version = "0.26", features = ["derive"] }
wasm-bindgen = { version = "0.2.92" }
wasm-bindgen = { version = "0.2.99" }

[lints]
workspace = true
20 changes: 5 additions & 15 deletions crates/hyperswitch_connectors/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,7 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
}
fn is_mandate_payment(&self) -> bool {
((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage.map_or(false, |setup_future_usage| {
setup_future_usage == FutureUsage::OffSession
}))
&& (self.setup_future_usage == Some(FutureUsage::OffSession)))
|| self
.mandate_id
.as_ref()
Expand Down Expand Up @@ -1409,9 +1407,7 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {

fn is_customer_initiated_mandate_payment(&self) -> bool {
(self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage.map_or(false, |setup_future_usage| {
setup_future_usage == FutureUsage::OffSession
})
&& self.setup_future_usage == Some(FutureUsage::OffSession)
}

fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue> {
Expand Down Expand Up @@ -1469,9 +1465,7 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
}
fn is_cit_mandate_payment(&self) -> bool {
(self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage.map_or(false, |setup_future_usage| {
setup_future_usage == FutureUsage::OffSession
})
&& self.setup_future_usage == Some(FutureUsage::OffSession)
}
}

Expand Down Expand Up @@ -1687,9 +1681,7 @@ impl PaymentsCompleteAuthorizeRequestData for CompleteAuthorizeData {
}
fn is_mandate_payment(&self) -> bool {
((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage.map_or(false, |setup_future_usage| {
setup_future_usage == FutureUsage::OffSession
}))
&& self.setup_future_usage == Some(FutureUsage::OffSession))
|| self
.mandate_id
.as_ref()
Expand All @@ -1712,9 +1704,7 @@ impl PaymentsCompleteAuthorizeRequestData for CompleteAuthorizeData {
}
fn is_cit_mandate_payment(&self) -> bool {
(self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage.map_or(false, |setup_future_usage| {
setup_future_usage == FutureUsage::OffSession
})
&& self.setup_future_usage == Some(FutureUsage::OffSession)
}
}
pub trait AddressData {
Expand Down
68 changes: 35 additions & 33 deletions crates/router/src/connector/authorizedotnet/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,39 +702,41 @@ impl
&domain::Card,
),
) -> Result<Self, Self::Error> {
let (profile, customer) = if item
.router_data
.request
.setup_future_usage
.map_or(false, |future_usage| {
matches!(future_usage, common_enums::FutureUsage::OffSession)
})
&& (item.router_data.request.customer_acceptance.is_some()
|| item
.router_data
.request
.setup_mandate_details
.clone()
.map_or(false, |mandate_details| {
mandate_details.customer_acceptance.is_some()
})) {
(
Some(ProfileDetails::CreateProfileDetails(CreateProfileDetails {
create_profile: true,
})),
Some(CustomerDetails {
//The payment ID is included in the customer details because the connector requires unique customer information with a length of fewer than 20 characters when creating a mandate.
//If the length exceeds 20 characters, a random alphanumeric string is used instead.
id: if item.router_data.payment_id.len() <= 20 {
item.router_data.payment_id.clone()
} else {
Alphanumeric.sample_string(&mut rand::thread_rng(), 20)
},
}),
)
} else {
(None, None)
};
let (profile, customer) =
if item
.router_data
.request
.setup_future_usage
.is_some_and(|future_usage| {
matches!(future_usage, common_enums::FutureUsage::OffSession)
})
&& (item.router_data.request.customer_acceptance.is_some()
|| item
.router_data
.request
.setup_mandate_details
.clone()
.is_some_and(|mandate_details| {
mandate_details.customer_acceptance.is_some()
}))
{
(
Some(ProfileDetails::CreateProfileDetails(CreateProfileDetails {
create_profile: true,
})),
Some(CustomerDetails {
//The payment ID is included in the customer details because the connector requires unique customer information with a length of fewer than 20 characters when creating a mandate.
//If the length exceeds 20 characters, a random alphanumeric string is used instead.
id: if item.router_data.payment_id.len() <= 20 {
item.router_data.payment_id.clone()
} else {
Alphanumeric.sample_string(&mut rand::thread_rng(), 20)
},
}),
)
} else {
(None, None)
};
Ok(Self {
transaction_type: TransactionType::try_from(item.router_data.request.capture_method)?,
amount: item.amount,
Expand Down
9 changes: 3 additions & 6 deletions crates/router/src/connector/bankofamerica/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,18 +619,15 @@ impl
.router_data
.request
.setup_future_usage
.map_or(false, |future_usage| {
matches!(future_usage, common_enums::FutureUsage::OffSession)
})
== Some(common_enums::FutureUsage::OffSession)
&& (item.router_data.request.customer_acceptance.is_some()
|| item
.router_data
.request
.setup_mandate_details
.clone()
.map_or(false, |mandate_details| {
mandate_details.customer_acceptance.is_some()
})) {
.is_some_and(|mandate_details| mandate_details.customer_acceptance.is_some()))
{
get_boa_mandate_action_details()
} else if item.router_data.request.connector_mandate_id().is_some() {
let original_amount = item
Expand Down
60 changes: 26 additions & 34 deletions crates/router/src/connector/cybersource/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,18 +632,15 @@ impl
.router_data
.request
.setup_future_usage
.map_or(false, |future_usage| {
matches!(future_usage, FutureUsage::OffSession)
})
== Some(FutureUsage::OffSession)
&& (item.router_data.request.customer_acceptance.is_some()
|| item
.router_data
.request
.setup_mandate_details
.clone()
.map_or(false, |mandate_details| {
mandate_details.customer_acceptance.is_some()
})) {
.is_some_and(|mandate_details| mandate_details.customer_acceptance.is_some()))
{
(
Some(vec![CybersourceActionsList::TokenCreate]),
Some(vec![
Expand Down Expand Up @@ -960,35 +957,30 @@ impl
let connector_merchant_config =
CybersourceConnectorMetadataObject::try_from(&item.router_data.connector_meta_data)?;

let (action_list, action_token_types, authorization_options) = if item
.router_data
.request
.setup_future_usage
.map_or(false, |future_usage| {
matches!(future_usage, FutureUsage::OffSession)
})
//TODO check for customer acceptance also
{
(
Some(vec![CybersourceActionsList::TokenCreate]),
Some(vec![
CybersourceActionsTokenType::PaymentInstrument,
CybersourceActionsTokenType::Customer,
]),
Some(CybersourceAuthorizationOptions {
initiator: Some(CybersourcePaymentInitiator {
initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
credential_stored_on_file: Some(true),
stored_credential_used: None,
let (action_list, action_token_types, authorization_options) =
if item.router_data.request.setup_future_usage == Some(FutureUsage::OffSession)
//TODO check for customer acceptance also
{
(
Some(vec![CybersourceActionsList::TokenCreate]),
Some(vec![
CybersourceActionsTokenType::PaymentInstrument,
CybersourceActionsTokenType::Customer,
]),
Some(CybersourceAuthorizationOptions {
initiator: Some(CybersourcePaymentInitiator {
initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
credential_stored_on_file: Some(true),
stored_credential_used: None,
}),
merchant_intitiated_transaction: None,
ignore_avs_result: connector_merchant_config.disable_avs,
ignore_cv_result: connector_merchant_config.disable_cvn,
}),
merchant_intitiated_transaction: None,
ignore_avs_result: connector_merchant_config.disable_avs,
ignore_cv_result: connector_merchant_config.disable_cvn,
}),
)
} else {
(None, None, None)
};
)
} else {
(None, None, None)
};
Ok(Self {
capture: Some(matches!(
item.router_data.request.capture_method,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/noon/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundSyncResponse>>
transaction
.transaction_reference
.clone()
.map_or(false, |transaction_instance| {
.is_some_and(|transaction_instance| {
transaction_instance == item.data.request.refund_id
})
})
Expand Down
Loading
Loading