Skip to content

Commit

Permalink
fix: More clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiesler committed Apr 26, 2024
1 parent 1a85b9b commit 7eb530d
Show file tree
Hide file tree
Showing 62 changed files with 128 additions and 46 deletions.
4 changes: 3 additions & 1 deletion openapi/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ pub fn gen_impl_requests(
out.push_str("> {\n");
out.push_str(" client.get_query(");
out.push_str(&format!("&format!(\"/{}/{{}}\", id)", segments[0]));
out.push_str(", &Expand { expand })\n");
out.push_str(", Expand { expand })\n");
} else {
out.push_str(") -> Response<");
out.push_str(&rust_struct);
Expand Down Expand Up @@ -1473,6 +1473,7 @@ pub fn gen_impl_requests(
out.push_str("<'_>) -> Response<");
out.push_str(&return_type);
out.push_str("> {\n");
out.push_str(" #[allow(clippy::needless_borrows_for_generic_args)]\n");
out.push_str(" client.post_form(\"/");
out.push_str(&segments.join("/"));
out.push_str("\", &params)\n");
Expand Down Expand Up @@ -1513,6 +1514,7 @@ pub fn gen_impl_requests(
out.push_str("<'_>) -> Response<");
out.push_str(&return_type);
out.push_str("> {\n");
out.push_str(" #[allow(clippy::needless_borrows_for_generic_args)]\n");
out.push_str(" client.post_form(");
out.push_str(&format!("&format!(\"/{}/{{}}\", id)", segments[0]));
out.push_str(", &params)\n");
Expand Down
6 changes: 6 additions & 0 deletions src/client/base/tokio_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ pub struct TokioBlockingClient {
runtime: Arc<tokio::runtime::Runtime>,
}

impl Default for TokioBlockingClient {
fn default() -> Self {
Self::new()
}
}

impl TokioBlockingClient {
/// Creates a new client pointed to `https://api.stripe.com/`
pub fn new() -> TokioBlockingClient {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
//! Otherwise, we are open to turning this into an open trait so that you can implement your own strategy.

#![allow(clippy::map_clone, clippy::large_enum_variant)]
#![warn(clippy::unwrap_used, clippy::missing_errors_doc, clippy::missing_panics_doc)]
#![warn(clippy::unwrap_used, clippy::missing_panics_doc)]
#![forbid(unsafe_code)]
// Workaround
#![allow(ambiguous_glob_reexports)]
Expand Down
2 changes: 1 addition & 1 deletion src/resources/checkout_session_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl CheckoutSession {
id: &CheckoutSessionId,
expand: &[&str],
) -> Response<CheckoutSession> {
client.get_query(&format!("/checkout/sessions/{}", id), &Expand { expand })
client.get_query(&format!("/checkout/sessions/{}", id), Expand { expand })
}

/// Expires a checkout session.
Expand Down
5 changes: 4 additions & 1 deletion src/resources/customer_balance_transaction_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl Customer {
customer_id: &CustomerId,
params: ListCustomerBalanceTransactions<'_>,
) -> Response<List<CustomerBalanceTransaction>> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.get_query(&format!("/customers/{}/balance_transactions", customer_id), &params)
}

Expand All @@ -106,6 +107,7 @@ impl Customer {
customer_id: &CustomerId,
params: CreateCustomerBalanceTransaction<'_>,
) -> Response<CustomerBalanceTransaction> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/customers/{}/balance_transactions", customer_id), &params)
}

Expand All @@ -118,7 +120,7 @@ impl Customer {
) -> Response<CustomerBalanceTransaction> {
client.get_query(
&format!("/customers/{}/balance_transactions/{}", customer_id, id),
&Expand { expand },
Expand { expand },
)
}

Expand All @@ -131,6 +133,7 @@ impl Customer {
id: &CustomerBalanceTransactionId,
params: UpdateCustomerBalanceTransaction<'_>,
) -> Response<CustomerBalanceTransaction> {
#[allow(clippy::needless_borrows_for_generic_args)]
client
.post_form(&format!("/customers/{}/balance_transactions/{}", customer_id, id), &params)
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/customer_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl Customer {
customer_id: &CustomerId,
params: CustomerPaymentMethodRetrieval<'_>,
) -> Response<List<PaymentMethod>> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.get_query(&format!("/customers/{}/payment_methods", customer_id), &params)
}

Expand Down
4 changes: 3 additions & 1 deletion src/resources/generated/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ impl Account {
///
/// Connect Onboarding won’t ask for the prefilled information during account onboarding. You can prefill any information on the account.
pub fn create(client: &Client, params: CreateAccount<'_>) -> Response<Account> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/accounts", &params)
}

/// Retrieves the details of an account.
pub fn retrieve(client: &Client, id: &AccountId, expand: &[&str]) -> Response<Account> {
client.get_query(&format!("/accounts/{}", id), &Expand { expand })
client.get_query(&format!("/accounts/{}", id), Expand { expand })
}

/// Updates a [connected account](https://stripe.com/docs/connect/accounts) by setting the values of the parameters passed.
Expand All @@ -148,6 +149,7 @@ impl Account {
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), some properties can only be changed or updated for Custom accounts. To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account).
/// Refer to our [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts.
pub fn update(client: &Client, id: &AccountId, params: UpdateAccount<'_>) -> Response<Account> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/accounts/{}", id), &params)
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/generated/account_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct AccountLink {
impl AccountLink {
/// Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.
pub fn create(client: &Client, params: CreateAccountLink<'_>) -> Response<AccountLink> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/account_links", &params)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/generated/account_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl AccountSession {

/// Creates a AccountSession object that includes a single-use token that the platform can use on their front-end to grant client-side API access.
pub fn create(client: &Client, params: CreateAccountSession<'_>) -> Response<AccountSession> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/account_sessions", &params)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/application_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl ApplicationFee {
id: &ApplicationFeeId,
expand: &[&str],
) -> Response<ApplicationFee> {
client.get_query(&format!("/application_fees/{}", id), &Expand { expand })
client.get_query(&format!("/application_fees/{}", id), Expand { expand })
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/balance_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl BalanceTransaction {
id: &BalanceTransactionId,
expand: &[&str],
) -> Response<BalanceTransaction> {
client.get_query(&format!("/balance_transactions/{}", id), &Expand { expand })
client.get_query(&format!("/balance_transactions/{}", id), Expand { expand })
}
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/generated/billing_portal_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl BillingPortalSession {
client: &Client,
params: CreateBillingPortalSession<'_>,
) -> Response<BillingPortalSession> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/billing_portal/sessions", &params)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/resources/generated/charge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl Charge {
///
/// Confirmation of the PaymentIntent creates the `Charge` object used to request payment.
pub fn create(client: &Client, params: CreateCharge<'_>) -> Response<Charge> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/charges", &params)
}

Expand All @@ -229,13 +230,14 @@ impl Charge {
/// Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information.
/// The same information is returned when creating or refunding the charge.
pub fn retrieve(client: &Client, id: &ChargeId, expand: &[&str]) -> Response<Charge> {
client.get_query(&format!("/charges/{}", id), &Expand { expand })
client.get_query(&format!("/charges/{}", id), Expand { expand })
}

/// Updates the specified charge by setting the values of the parameters passed.
///
/// Any parameters not provided will be left unchanged.
pub fn update(client: &Client, id: &ChargeId, params: UpdateCharge<'_>) -> Response<Charge> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/charges/{}", id), &params)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/generated/checkout_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ impl CheckoutSession {

/// Creates a Session object.
pub fn create(client: &Client, params: CreateCheckoutSession<'_>) -> Response<CheckoutSession> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/checkout/sessions", &params)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/country_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn list(client: &Client, params: &ListCountrySpecs<'_>) -> Response<List<Cou

/// Returns a Country Spec for a given Country code.
pub fn retrieve(client: &Client, id: &CountrySpecId, expand: &[&str]) -> Response<CountrySpec> {
client.get_query(&format!("/country_specs/{}", id), &Expand { expand })
client.get_query(&format!("/country_specs/{}", id), Expand { expand })
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/resources/generated/coupon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,20 @@ impl Coupon {
/// If you set an `amount_off`, that amount will be subtracted from any invoice’s subtotal.
/// For example, an invoice with a subtotal of $100 will have a final total of $0 if a coupon with an `amount_off` of 20000 is applied to it and an invoice with a subtotal of $300 will have a final total of $100 if a coupon with an `amount_off` of 20000 is applied to it.
pub fn create(client: &Client, params: CreateCoupon<'_>) -> Response<Coupon> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/coupons", &params)
}

/// Retrieves the coupon with the given ID.
pub fn retrieve(client: &Client, id: &CouponId, expand: &[&str]) -> Response<Coupon> {
client.get_query(&format!("/coupons/{}", id), &Expand { expand })
client.get_query(&format!("/coupons/{}", id), Expand { expand })
}

/// Updates the metadata of a coupon.
///
/// Other coupon details (currency, duration, amount_off) are, by design, not editable.
pub fn update(client: &Client, id: &CouponId, params: UpdateCoupon<'_>) -> Response<Coupon> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/coupons/{}", id), &params)
}

Expand Down
4 changes: 3 additions & 1 deletion src/resources/generated/credit_note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ impl CreditNote {
/// Instead, it can result in any combination of the following: <ul> <li>Refund: create a new refund (using `refund_amount`) or link an existing refund (using `refund`).</li> <li>Customer balance credit: credit the customer’s balance (using `credit_amount`) which will be automatically applied to their next invoice when it’s finalized.</li> <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using `out_of_band_amount`).</li> </ul> For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. You may issue multiple credit notes for an invoice.
/// Each credit note will increment the invoice’s `pre_payment_credit_notes_amount` or `post_payment_credit_notes_amount` depending on its `status` at the time of credit note creation.
pub fn create(client: &Client, params: CreateCreditNote<'_>) -> Response<CreditNote> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/credit_notes", &params)
}

/// Retrieves the credit note object with the given identifier.
pub fn retrieve(client: &Client, id: &CreditNoteId, expand: &[&str]) -> Response<CreditNote> {
client.get_query(&format!("/credit_notes/{}", id), &Expand { expand })
client.get_query(&format!("/credit_notes/{}", id), Expand { expand })
}

/// Updates an existing credit note.
Expand All @@ -147,6 +148,7 @@ impl CreditNote {
id: &CreditNoteId,
params: UpdateCreditNote<'_>,
) -> Response<CreditNote> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/credit_notes/{}", id), &params)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/resources/generated/customer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ impl Customer {

/// Creates a new customer object.
pub fn create(client: &Client, params: CreateCustomer<'_>) -> Response<Customer> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/customers", &params)
}

/// Retrieves a Customer object.
pub fn retrieve(client: &Client, id: &CustomerId, expand: &[&str]) -> Response<Customer> {
client.get_query(&format!("/customers/{}", id), &Expand { expand })
client.get_query(&format!("/customers/{}", id), Expand { expand })
}

/// Updates the specified customer by setting the values of the parameters passed.
Expand All @@ -190,6 +191,7 @@ impl Customer {
id: &CustomerId,
params: UpdateCustomer<'_>,
) -> Response<Customer> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/customers/{}", id), &params)
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/generated/customer_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl CustomerSession {

/// Creates a customer session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources.
pub fn create(client: &Client, params: CreateCustomerSession<'_>) -> Response<CustomerSession> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/customer_sessions", &params)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Dispute {

/// Retrieves the dispute with the given ID.
pub fn retrieve(client: &Client, id: &DisputeId, expand: &[&str]) -> Response<Dispute> {
client.get_query(&format!("/disputes/{}", id), &Expand { expand })
client.get_query(&format!("/disputes/{}", id), Expand { expand })
}
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/generated/ephemeral_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct EphemeralKey {
impl EphemeralKey {
/// Creates a short-lived API key for a given resource.
pub fn create(client: &Client, params: CreateEphemeralKey<'_>) -> Response<EphemeralKey> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/ephemeral_keys", &params)
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Event {
///
/// Supply the unique identifier of the event, which you might have received in a webhook.
pub fn retrieve(client: &Client, id: &EventId, expand: &[&str]) -> Response<Event> {
client.get_query(&format!("/events/{}", id), &Expand { expand })
client.get_query(&format!("/events/{}", id), Expand { expand })
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/exchange_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn list(client: &Client, params: &ListExchangeRates<'_>) -> Response<List<Ex

/// Retrieves the exchange rates from the given currency to every supported currency.
pub fn retrieve(client: &Client, id: &ExchangeRateId, expand: &[&str]) -> Response<ExchangeRate> {
client.get_query(&format!("/exchange_rates/{}", id), &Expand { expand })
client.get_query(&format!("/exchange_rates/{}", id), Expand { expand })
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl File {
/// After you supply a unique file ID, Stripe returns the corresponding file object.
/// Learn how to [access file contents](https://stripe.com/docs/file-upload#download-file-contents).
pub fn retrieve(client: &Client, id: &FileId, expand: &[&str]) -> Response<File> {
client.get_query(&format!("/files/{}", id), &Expand { expand })
client.get_query(&format!("/files/{}", id), Expand { expand })
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/resources/generated/file_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ impl FileLink {

/// Creates a new file link object.
pub fn create(client: &Client, params: CreateFileLink<'_>) -> Response<FileLink> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/file_links", &params)
}

/// Retrieves the file link with the given ID.
pub fn retrieve(client: &Client, id: &FileLinkId, expand: &[&str]) -> Response<FileLink> {
client.get_query(&format!("/file_links/{}", id), &Expand { expand })
client.get_query(&format!("/file_links/{}", id), Expand { expand })
}

/// Updates an existing file link object.
Expand All @@ -67,6 +68,7 @@ impl FileLink {
id: &FileLinkId,
params: UpdateFileLink<'_>,
) -> Response<FileLink> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/file_links/{}", id), &params)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/generated/financial_connections_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl FinancialConnectionsSession {
///
/// The session’s `client_secret` can be used to launch the flow using Stripe.js.
pub fn create(client: &Client, params: CreateFinancialConnectionsSession<'_>) -> Response<FinancialConnectionsSession> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/financial_connections/sessions", &params)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/resources/generated/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,13 @@ impl Invoice {
///
/// The invoice remains a draft until you [finalize](https://stripe.com/docs/api#finalize_invoice) the invoice, which allows you to [pay](https://stripe.com/docs/api#pay_invoice) or [send](https://stripe.com/docs/api#send_invoice) the invoice to your customers.
pub fn create(client: &Client, params: CreateInvoice<'_>) -> Response<Invoice> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/invoices", &params)
}

/// Retrieves the invoice with the given ID.
pub fn retrieve(client: &Client, id: &InvoiceId, expand: &[&str]) -> Response<Invoice> {
client.get_query(&format!("/invoices/{}", id), &Expand { expand })
client.get_query(&format!("/invoices/{}", id), Expand { expand })
}

/// Permanently deletes a one-off invoice draft.
Expand Down
4 changes: 3 additions & 1 deletion src/resources/generated/invoiceitem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ impl InvoiceItem {
///
/// If no invoice is specified, the item will be on the next invoice created for the customer specified.
pub fn create(client: &Client, params: CreateInvoiceItem<'_>) -> Response<InvoiceItem> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form("/invoiceitems", &params)
}

/// Retrieves the invoice item with the given ID.
pub fn retrieve(client: &Client, id: &InvoiceItemId, expand: &[&str]) -> Response<InvoiceItem> {
client.get_query(&format!("/invoiceitems/{}", id), &Expand { expand })
client.get_query(&format!("/invoiceitems/{}", id), Expand { expand })
}

/// Updates the amount or description of an invoice item on an upcoming invoice.
Expand All @@ -157,6 +158,7 @@ impl InvoiceItem {
id: &InvoiceItemId,
params: UpdateInvoiceItem<'_>,
) -> Response<InvoiceItem> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/invoiceitems/{}", id), &params)
}

Expand Down

0 comments on commit 7eb530d

Please sign in to comment.