Skip to content

Commit 2123f63

Browse files
chore: address Rust 1.86.0 clippy lints (#7735)
1 parent b83e044 commit 2123f63

File tree

20 files changed

+49
-44
lines changed

20 files changed

+49
-44
lines changed

crates/common_utils/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<const PRECISION: u8> Percentage<PRECISION> {
125125
fn is_valid_precision_length(value: &str) -> bool {
126126
if value.contains('.') {
127127
// if string has '.' then take the decimal part and verify precision length
128-
match value.split('.').last() {
128+
match value.split('.').next_back() {
129129
Some(decimal_part) => {
130130
decimal_part.trim_end_matches('0').len() <= <u8 as Into<usize>>::into(PRECISION)
131131
}

crates/common_utils/src/validation.rs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub fn validate_phone_number(phone_number: &str) -> Result<(), ValidationError>
2626
pub fn validate_email(email: &str) -> CustomResult<(), ValidationError> {
2727
#[deny(clippy::invalid_regex)]
2828
static EMAIL_REGEX: Lazy<Option<Regex>> = Lazy::new(|| {
29+
#[allow(unknown_lints)]
30+
#[allow(clippy::manual_ok_err)]
2931
match Regex::new(
3032
r"^(?i)[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$",
3133
) {

crates/euclid/src/backend/vir_interpreter.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ where
4040
}
4141

4242
fn eval_statement(stmt: &vir::ValuedIfStatement, ctx: &types::Context) -> bool {
43-
Self::eval_condition(&stmt.condition, ctx)
44-
.then(|| {
43+
if Self::eval_condition(&stmt.condition, ctx) {
44+
{
4545
stmt.nested.as_ref().map_or(true, |nested_stmts| {
4646
nested_stmts.iter().any(|s| Self::eval_statement(s, ctx))
4747
})
48-
})
49-
.unwrap_or(false)
48+
}
49+
} else {
50+
false
51+
}
5052
}
5153

5254
fn eval_rule(rule: &vir::ValuedRule<O>, ctx: &types::Context) -> bool {

crates/hyperswitch_connectors/src/connectors/bluesnap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
747747
.change_context(errors::ConnectorError::ResponseHandlingFailed)?; // If location headers are not present connector will return 4XX so this error will never be propagated
748748
let payment_fields_token = location
749749
.split('/')
750-
.last()
750+
.next_back()
751751
.ok_or(errors::ConnectorError::ResponseHandlingFailed)?
752752
.to_string();
753753

crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> for Blues
308308
let apple_pay_payment_data =
309309
payment_method_data.get_applepay_decoded_payment_data()?;
310310
let apple_pay_payment_data: ApplePayEncodedPaymentData = apple_pay_payment_data
311-
.expose()[..]
311+
.expose()
312312
.as_bytes()
313313
.parse_struct("ApplePayEncodedPaymentData")
314314
.change_context(errors::ConnectorError::InvalidWalletToken {

crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ impl ChargebeeCustomer {
402402
.ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)?
403403
.to_string();
404404
let mandate_id = parts
405-
.last()
405+
.next_back()
406406
.ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)?
407407
.to_string();
408408
Ok(ChargebeeMandateDetails {

crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ pub fn construct_file_upload_request(
13731373
.file_type
13741374
.as_ref()
13751375
.split('/')
1376-
.last()
1376+
.next_back()
13771377
.unwrap_or_default()
13781378
))
13791379
.mime_str(request.file_type.as_ref())

crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>>
7878
| PaymentMethodData::BankRedirect(_)
7979
| PaymentMethodData::BankDebit(_)
8080
| PaymentMethodData::BankTransfer(_)
81-
| PaymentMethodData::MandatePayment {}
82-
| PaymentMethodData::Reward {}
81+
| PaymentMethodData::MandatePayment
82+
| PaymentMethodData::Reward
8383
| PaymentMethodData::RealTimePayment(_)
8484
| PaymentMethodData::Upi(_)
8585
| PaymentMethodData::MobilePayment(_)

crates/hyperswitch_connectors/src/connectors/forte/transformers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ impl TryFrom<&ForteRouterData<&types::PaymentsAuthorizeRouterData>> for FortePay
137137
| PaymentMethodData::BankDebit(_)
138138
| PaymentMethodData::BankTransfer(_)
139139
| PaymentMethodData::Crypto(_)
140-
| PaymentMethodData::MandatePayment {}
141-
| PaymentMethodData::Reward {}
140+
| PaymentMethodData::MandatePayment
141+
| PaymentMethodData::Reward
142142
| PaymentMethodData::RealTimePayment(_)
143143
| PaymentMethodData::MobilePayment(_)
144144
| PaymentMethodData::Upi(_)

crates/hyperswitch_connectors/src/connectors/noon/transformers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ impl TryFrom<&NoonRouterData<&PaymentsAuthorizeRouterData>> for NoonPaymentsRequ
353353
| PaymentMethodData::BankDebit(_)
354354
| PaymentMethodData::BankTransfer(_)
355355
| PaymentMethodData::Crypto(_)
356-
| PaymentMethodData::MandatePayment {}
357-
| PaymentMethodData::Reward {}
356+
| PaymentMethodData::MandatePayment
357+
| PaymentMethodData::Reward
358358
| PaymentMethodData::RealTimePayment(_)
359359
| PaymentMethodData::MobilePayment(_)
360360
| PaymentMethodData::Upi(_)

crates/hyperswitch_connectors/src/connectors/paypal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl Paypal {
148148
if let Some(field) = error
149149
.field
150150
.as_ref()
151-
.and_then(|field| field.split('/').last())
151+
.and_then(|field| field.split('/').next_back())
152152
{
153153
reason.push_str(&format!(", field - {field}"));
154154
}

crates/hyperswitch_connectors/src/connectors/square/transformers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ impl TryFrom<&ConnectorAuthType> for SquareAuthType {
331331
| ConnectorAuthType::SignatureKey { .. }
332332
| ConnectorAuthType::MultiAuthKey { .. }
333333
| ConnectorAuthType::CurrencyAuthKey { .. }
334-
| ConnectorAuthType::TemporaryAuth { .. }
335-
| ConnectorAuthType::NoKey { .. }
334+
| ConnectorAuthType::TemporaryAuth
335+
| ConnectorAuthType::NoKey
336336
| ConnectorAuthType::CertificateAuth { .. } => {
337337
Err(errors::ConnectorError::FailedToObtainAuthType.into())
338338
}

crates/hyperswitch_connectors/src/connectors/volt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ impl webhooks::IncomingWebhook for Volt {
663663
let user_agent = utils::get_header_key_value(webhook_headers::USER_AGENT, request.headers)?;
664664
let version = user_agent
665665
.split('/')
666-
.last()
666+
.next_back()
667667
.ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?;
668668
Ok(format!(
669669
"{}|{}|{}",

crates/hyperswitch_connectors/src/connectors/worldpay.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1099,13 +1099,14 @@ impl IncomingWebhook for Worldpay {
10991099
request: &IncomingWebhookRequestDetails<'_>,
11001100
_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,
11011101
) -> CustomResult<Vec<u8>, errors::ConnectorError> {
1102-
let event_signature = get_header_key_value("Event-Signature", request.headers)?.split(',');
1102+
let mut event_signature =
1103+
get_header_key_value("Event-Signature", request.headers)?.split(',');
11031104
let sign_header = event_signature
1104-
.last()
1105+
.next_back()
11051106
.ok_or(errors::ConnectorError::WebhookSignatureNotFound)?;
11061107
let signature = sign_header
11071108
.split('/')
1108-
.last()
1109+
.next_back()
11091110
.ok_or(errors::ConnectorError::WebhookSignatureNotFound)?;
11101111
hex::decode(signature).change_context(errors::ConnectorError::WebhookResponseEncodingFailed)
11111112
}

crates/hyperswitch_connectors/src/connectors/zen/transformers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl
282282
VoucherData::PagoEfectivo => ZenPaymentChannels::PclBoacompraPagoefectivo,
283283
VoucherData::RedCompra => ZenPaymentChannels::PclBoacompraRedcompra,
284284
VoucherData::RedPagos => ZenPaymentChannels::PclBoacompraRedpagos,
285-
VoucherData::Oxxo { .. }
285+
VoucherData::Oxxo
286286
| VoucherData::Alfamart { .. }
287287
| VoucherData::Indomaret { .. }
288288
| VoucherData::SevenEleven { .. }

crates/router/src/connector/netcetera/netcetera_types.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1113,8 +1113,8 @@ pub struct MerchantRiskIndicator {
11131113
/// New field introduced:
11141114
/// - transChar -> Indicates to the ACS specific transactions identified by the Merchant.
11151115
/// - Size: Variable, 1-2 elements. JSON Data Type: Array of String. Accepted values:
1116-
/// - 01 -> Cryptocurrency transaction
1117-
/// - 02 -> NFT transaction
1116+
/// - 01 -> Cryptocurrency transaction
1117+
/// - 02 -> NFT transaction
11181118
trans_char: Option<String>,
11191119
}
11201120

@@ -1558,19 +1558,19 @@ pub struct Sdk {
15581558
/// Creates a JSON object of the following data as the JWS payload to be signed:
15591559
///
15601560
/// - SDK Reference Number -> Identifies the vendor and version of the 3DS SDK that is utilised for a specific
1561-
/// transaction. The value is assigned by EMVCo when the Letter of Approval of the
1562-
/// specific 3DS SDK is issued. The field is limited to 32 characters.
1561+
/// transaction. The value is assigned by EMVCo when the Letter of Approval of the
1562+
/// specific 3DS SDK is issued. The field is limited to 32 characters.
15631563
/// - SDK Signature Timestamp -> Date and time indicating when the 3DS SDK generated the Split-SDK Server Signed
1564-
/// Content converted into UTC. The value is limited to 14 characters. Accepted
1565-
/// format: YYYYMMDDHHMMSS.
1564+
/// Content converted into UTC. The value is limited to 14 characters. Accepted
1565+
/// format: YYYYMMDDHHMMSS.
15661566
/// - SDK Transaction ID -> Universally unique transaction identifier assigned by the 3DS SDK to identify a
1567-
/// single transaction. The field is limited to 36 characters and it shall be in a
1568-
/// canonical format as defined in IETF RFC 4122. This may utilize any of the specified
1569-
/// versions as long as the output meets specific requirements.
1567+
/// single transaction. The field is limited to 36 characters and it shall be in a
1568+
/// canonical format as defined in IETF RFC 4122. This may utilize any of the specified
1569+
/// versions as long as the output meets specific requirements.
15701570
/// - Split-SDK Server ID -> DS assigned Split-SDK Server identifier. Each DS can provide a unique ID to each
1571-
/// Split-SDK Server on an individual basis. The field is limited to 32 characters.
1572-
/// Any individual DS may impose specific formatting and character requirements on the
1573-
/// contents of this field.
1571+
/// Split-SDK Server on an individual basis. The field is limited to 32 characters.
1572+
/// Any individual DS may impose specific formatting and character requirements on the
1573+
/// contents of this field.
15741574
///
15751575
/// Generates a digital signature of the full JSON object according to JWS (RFC 7515) using JWS Compact
15761576
/// Serialization. The parameter values for this version of the specification and to be included in the JWS
@@ -1705,7 +1705,7 @@ pub struct SplitSdkType {
17051705
/// Limited Split-SDK Indicator: If the Split-SDK client has limited capabilities
17061706
/// - Length: 1 character
17071707
/// - Value accepted:
1708-
/// • Y = Limited
1708+
/// • Y = Limited
17091709
/// - Only present if value = Y
17101710
limited_ind: Option<String>,
17111711
}

crates/router/src/connector/netcetera/transformers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,9 @@ pub struct ResultsResponseData {
700700
/// - `U`: Authentication / Account verification could not be performed; technical or other problem.
701701
/// - `C`: A challenge is required to complete the authentication.
702702
/// - `R`: Authentication / Account verification Rejected. Issuer is rejecting authentication/verification
703-
/// and request that authorization not be attempted.
703+
/// and request that authorization not be attempted.
704704
/// - `A`: Attempts processing performed; Not authenticated / verified, but a proof of attempt
705-
/// authentication / verification is provided.
705+
/// authentication / verification is provided.
706706
/// - `D`: A challenge is required to complete the authentication. Decoupled Authentication confirmed.
707707
/// - `I`: Informational Only; 3DS Requestor challenge preference acknowledged.
708708
pub trans_status: Option<common_enums::TransactionStatus>,

crates/router/src/core/errors/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>
178178
| errors::ConnectorError::RequestTimeoutReceived
179179
| errors::ConnectorError::CurrencyNotSupported { .. }
180180
| errors::ConnectorError::InvalidConnectorConfig { .. }
181-
| errors::ConnectorError::AmountConversionFailed { .. }
181+
| errors::ConnectorError::AmountConversionFailed
182182
| errors::ConnectorError::GenericError { .. } => {
183183
err.change_context(errors::ApiErrorResponse::RefundFailed { data: None })
184184
}
@@ -369,7 +369,7 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>
369369
| errors::ConnectorError::RequestTimeoutReceived
370370
| errors::ConnectorError::CurrencyNotSupported { .. }
371371
| errors::ConnectorError::ProcessingStepFailed(None)
372-
| errors::ConnectorError::AmountConversionFailed { .. }
372+
| errors::ConnectorError::AmountConversionFailed
373373
| errors::ConnectorError::GenericError { .. } => {
374374
logger::error!(%error,"Setup Mandate flow failed");
375375
errors::ApiErrorResponse::PaymentAuthorizationFailed { data: None }

crates/router/src/events/audit_events.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ impl Event for AuditEvent {
7878
AuditEventType::RefundFail => "refund_fail",
7979
AuditEventType::PaymentCancelled { .. } => "payment_cancelled",
8080
AuditEventType::PaymentUpdate { .. } => "payment_update",
81-
AuditEventType::PaymentApprove { .. } => "payment_approve",
82-
AuditEventType::PaymentCreate { .. } => "payment_create",
83-
AuditEventType::PaymentStatus { .. } => "payment_status",
81+
AuditEventType::PaymentApprove => "payment_approve",
82+
AuditEventType::PaymentCreate => "payment_create",
83+
AuditEventType::PaymentStatus => "payment_status",
8484
AuditEventType::PaymentCompleteAuthorize => "payment_complete_authorize",
8585
AuditEventType::PaymentReject { .. } => "payment_rejected",
8686
};

crates/router/tests/connectors/cashtocode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl CashtocodeTest {
6868
router_return_url: Some(String::from("https://google.com")),
6969
webhook_url: None,
7070
complete_authorize_url: None,
71-
customer_id: if let Ok(id) = cust_id { Some(id) } else { None },
71+
customer_id: cust_id.ok(),
7272
surcharge_details: None,
7373
request_incremental_authorization: false,
7474
metadata: None,

0 commit comments

Comments
 (0)