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

Enforce linter on all files and packages #641

Merged
merged 7 commits into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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
58 changes: 1 addition & 57 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,8 @@ build:
check-gofmt:
scripts/check_gofmt.sh

# We're trying to get linting activated, but there are so many errors that
# we're doing so incrementally instead of pushing it through as part of one
# giant patch.
#
# As new packages get cleaned up, add them here so that we don't regress. When
# all packages are here, switch to a `./...` instead of linting every package
# individually.
lint:
golint -set_exit_status ./account
golint -set_exit_status ./applepaydomain
golint -set_exit_status ./balance
golint -set_exit_status ./bankaccount
golint -set_exit_status ./bitcoinreceiver
golint -set_exit_status ./bitcointransaction
golint -set_exit_status ./card
golint -set_exit_status ./charge
golint -set_exit_status ./countryspec
golint -set_exit_status ./coupon
golint -set_exit_status ./customer
golint -set_exit_status ./discount
golint -set_exit_status ./dispute
golint -set_exit_status ./ephemeralkey
golint -set_exit_status ./event
golint -set_exit_status ./exchangerate
golint -set_exit_status ./fee
golint -set_exit_status ./feerefund
golint -set_exit_status ./fileupload
golint -set_exit_status ./invoice
golint -set_exit_status ./invoiceitem
golint -set_exit_status ./issuerfraudrecord
golint -set_exit_status ./issuing/authorization
golint -set_exit_status ./issuing/card
golint -set_exit_status ./issuing/cardholder
golint -set_exit_status ./issuing/dispute
golint -set_exit_status ./issuing/transaction
golint -set_exit_status ./loginlink
golint -set_exit_status ./order
golint -set_exit_status ./orderreturn
golint -set_exit_status ./paymentintent
golint -set_exit_status ./paymentsource
golint -set_exit_status ./payout
golint -set_exit_status ./plan
golint -set_exit_status ./product
golint -set_exit_status ./recipient
golint -set_exit_status ./recipienttransfer
golint -set_exit_status ./refund
golint -set_exit_status ./reversal
golint -set_exit_status ./sigma/scheduledqueryrun
golint -set_exit_status ./sku
golint -set_exit_status ./source
golint -set_exit_status ./sourcetransaction
golint -set_exit_status ./sub
golint -set_exit_status ./subitem
golint -set_exit_status ./threedsecure
golint -set_exit_status ./token
golint -set_exit_status ./topup
golint -set_exit_status ./transfer
golint -set_exit_status ./usagerecord
golint -set_exit_status ./...

test:
go test -race ./...
Expand Down
22 changes: 16 additions & 6 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// AccountType is the type of an account.
type AccountType string

// List of values that AccountType can take.
const (
AccountTypeCustom AccountType = "custom"
AccountTypeExpress AccountType = "express"
Expand All @@ -18,6 +19,7 @@ const (
// ExternalAccountType is the type of an external account.
type ExternalAccountType string

// List of values that ExternalAccountType can take.
const (
ExternalAccountTypeBankAccount ExternalAccountType = "bank_account"
ExternalAccountTypeCard ExternalAccountType = "card"
Expand All @@ -26,6 +28,7 @@ const (
// LegalEntityType describes the types for a legal entity.
type LegalEntityType string

// List of values that LegalEntityType can take.
const (
LegalEntityTypeCompany LegalEntityType = "company"
LegalEntityTypeIndividual LegalEntityType = "individual"
Expand All @@ -35,14 +38,15 @@ const (
// verification state of a legal entity
type IdentityVerificationDetailsCode string

// List of values that IdentityVerificationDetailsCode can take.
const (
IdentityVerificationDetailsCodeFailedKeyedIdentity IdentityVerificationDetailsCode = "failed_keyed_identity"
IdentityVerificationDetailsCodeFailedOther IdentityVerificationDetailsCode = "failed_other"
IdentityVerificationDetailsCodeScanCorrupt IdentityVerificationDetailsCode = "scan_corrupt"
IdentityVerificationDetailsCodeScanFailedGreyscale IdentityVerificationDetailsCode = "scan_failed_greyscale"
IdentityVerificationDetailsCodeScanFailedOther IdentityVerificationDetailsCode = "scan_failed_other"
IdentityVerificationDetailsCodeScanIdCountryNotSupported IdentityVerificationDetailsCode = "scan_id_country_not_supported"
IdentityVerificationDetailsCodeScanIdTypeNotSupported IdentityVerificationDetailsCode = "scan_id_type_not_supported"
IdentityVerificationDetailsCodeScanIDCountryNotSupported IdentityVerificationDetailsCode = "scan_id_country_not_supported"
IdentityVerificationDetailsCodeScanIDTypeNotSupported IdentityVerificationDetailsCode = "scan_id_type_not_supported"
IdentityVerificationDetailsCodeScanNameMismatch IdentityVerificationDetailsCode = "scan_name_mismatch"
IdentityVerificationDetailsCodeScanNotReadable IdentityVerificationDetailsCode = "scan_not_readable"
IdentityVerificationDetailsCodeScanNotUploaded IdentityVerificationDetailsCode = "scan_not_uploaded"
Expand All @@ -51,6 +55,7 @@ const (
// IdentityVerificationDisabledReason describes the valid reason to disable account
type IdentityVerificationDisabledReason string

// List of values that IdentityVerificationDisabledReason can take.
const (
IdentityVerificationDisabledReasonFieldsNeeded IdentityVerificationDisabledReason = "fields_needed"
IdentityVerificationDisabledReasonListed IdentityVerificationDisabledReason = "listed"
Expand All @@ -65,15 +70,17 @@ const (
// IdentityVerificationStatus describes the different statuses for identity verification.
type IdentityVerificationStatus string

// List of values that IdentityVerificationStatus can take.
const (
IdentityVerificationStatusPending IdentityVerificationStatus = "pending"
IdentityVerificationStatusUnverified IdentityVerificationStatus = "unverified"
IdentityVerificationStatusVerified IdentityVerificationStatus = "verified"
)

// Interval describes the payout interval.
// PayoutInterval describes the payout interval.
type PayoutInterval string

// List of values that PayoutInterval can take.
const (
PayoutIntervalDaily PayoutInterval = "daily"
PayoutIntervalManual PayoutInterval = "manual"
Expand All @@ -84,6 +91,7 @@ const (
// AccountRejectReason describes the valid reason to reject an account
type AccountRejectReason string

// List of values that AccountRejectReason can take.
const (
AccountRejectReasonFraud AccountRejectReason = "fraud"
AccountRejectReasonOther AccountRejectReason = "other"
Expand Down Expand Up @@ -197,7 +205,7 @@ type AdditionalOwnerParams struct {
Verification *IdentityVerificationParams `form:"verification"`
}

// IdentityVerification represents a verification during account creation/updates.
// IdentityVerificationParams represents a verification during account creation/updates.
type IdentityVerificationParams struct {
Document *string `form:"document"`
DocumentBack *string `form:"document_back"`
Expand All @@ -224,7 +232,7 @@ type AccountExternalAccountParams struct {

// AppendTo implements custom encoding logic for AccountExternalAccountParams
// so that we can send the special required `object` field up along with the
// other specified parameters or the token value
// other specified parameters or the token value.
func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []string) {
if p.Token != nil {
body.Add(form.FormatKey(keyParts), StringValue(p.Token))
Expand All @@ -242,6 +250,8 @@ type PayoutScheduleParams struct {
WeeklyAnchor *string `form:"weekly_anchor"`
}

// AppendTo implements custom encoding logic for PayoutScheduleParams
// so that we can send a special value for `delay_days` field if needed.
func (p *PayoutScheduleParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.DelayDaysMinimum) {
body.Add(form.FormatKey(append(keyParts, "delay_days")), "minimum")
Expand Down Expand Up @@ -403,7 +413,7 @@ type LegalEntity struct {
Verification *IdentityVerification `json:"verification"`
}

// Address is the structure for an account address.
// AccountAddress is the structure for an account address.
type AccountAddress struct {
City string `json:"city"`
Country string `json:"country"`
Expand Down
4 changes: 2 additions & 2 deletions address.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package stripe

// Standard address parameters.
// AddressParams describes the common parameters for an Address.
type AddressParams struct {
City *string `form:"city"`
Country *string `form:"country"`
Expand All @@ -10,7 +10,7 @@ type AddressParams struct {
State *string `form:"state"`
}

// Standard address resource.
// Address describes common properties for an Address hash.
type Address struct {
City string `json:"city"`
Country string `json:"country"`
Expand Down
1 change: 1 addition & 0 deletions application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package stripe

import "encoding/json"

// Application describes the properties for an Application.
type Application struct {
ID string `json:"id"`
Name string `json:"name"`
Expand Down
3 changes: 3 additions & 0 deletions balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "encoding/json"
// BalanceTransactionStatus is the list of allowed values for the balance transaction's status.
type BalanceTransactionStatus string

// List of values that BalanceTransactionStatus can take.
const (
BalanceTransactionStatusAvailable BalanceTransactionStatus = "available"
BalanceTransactionStatusPending BalanceTransactionStatus = "pending"
Expand All @@ -13,6 +14,7 @@ const (
// BalanceTransactionType is the list of allowed values for the balance transaction's type.
type BalanceTransactionType string

// List of values that BalanceTransactionType can take.
const (
BalanceTransactionTypeAdjustment BalanceTransactionType = "adjustment"
BalanceTransactionTypeApplicationFee BalanceTransactionType = "application_fee"
Expand All @@ -39,6 +41,7 @@ const (
// BalanceTransactionSourceType consts represent valid balance transaction sources.
type BalanceTransactionSourceType string

// List of values that BalanceTransactionSourceType can take.
const (
BalanceTransactionSourceTypeApplicationFee BalanceTransactionSourceType = "application_fee"
BalanceTransactionSourceTypeCharge BalanceTransactionSourceType = "charge"
Expand Down
5 changes: 5 additions & 0 deletions bankaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// BankAccountStatus is the list of allowed values for the bank account's status.
type BankAccountStatus string

// List of values that BankAccountStatus can take.
const (
BankAccountStatusErrored BankAccountStatus = "errored"
BankAccountStatusNew BankAccountStatus = "new"
Expand All @@ -21,6 +22,7 @@ const (
// BankAccountAccountHolderType is the list of allowed values for the bank account holder type.
type BankAccountAccountHolderType string

// List of values that BankAccountAccountHolderType can take.
const (
BankAccountAccountHolderTypeCompany BankAccountAccountHolderType = "company"
BankAccountAccountHolderTypeIndividual BankAccountAccountHolderType = "individual"
Expand Down Expand Up @@ -125,6 +127,9 @@ type BankAccountListParams struct {
Customer *string `form:"-"`
}

// AppendTo implements custom encoding logic for BankAccountListParams
// so that we can send the special required `object` field up along with the
// other specified parameters.
func (p *BankAccountListParams) AppendTo(body *form.Values, keyParts []string) {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
}
Expand Down
2 changes: 1 addition & 1 deletion bitcoinreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type BitcoinReceiver struct {
AmountReceived int64 `json:"amount_received"`
BitcoinAmount int64 `json:"bitcoin_amount"`
BitcoinAmountReceived int64 `json:"bitcoin_amount_received"`
BitcoinUri string `json:"bitcoin_uri"`
BitcoinURI string `json:"bitcoin_uri"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Customer string `json:"customer"`
Expand Down
7 changes: 7 additions & 0 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// CardBrand is the list of allowed values for the card's brand.
type CardBrand string

// List of values that CardBrand can take.
const (
CardBrandAmex CardBrand = "American Express"
CardBrandDiscover CardBrand = "Discover"
Expand All @@ -24,6 +25,7 @@ const (
// CardFunding is the list of allowed values for the card's funding.
type CardFunding string

// List of values that CardFunding can take.
const (
CardFundingCredit CardFunding = "credit"
CardFundingDebit CardFunding = "debit"
Expand All @@ -34,6 +36,7 @@ const (
// CardTokenizationMethod is the list of allowed values for the card's tokenization method.
type CardTokenizationMethod string

// List of values that CardTokenizationMethod can take.
const (
TokenizationMethodAndroidPay CardTokenizationMethod = "android_pay"
TokenizationMethodApplePay CardTokenizationMethod = "apple_pay"
Expand All @@ -42,6 +45,7 @@ const (
// CardVerification is the list of allowed verification responses.
type CardVerification string

// List of values that CardVerification can take.
const (
CardVerificationFail CardVerification = "fail"
CardVerificationPass CardVerification = "pass"
Expand Down Expand Up @@ -168,6 +172,9 @@ type CardListParams struct {
Recipient *string `form:"-"`
}

// AppendTo implements custom encoding logic for CardListParams
// so that we can send the special required `object` field up along with the
// other specified parameters.
func (p *CardListParams) AppendTo(body *form.Values, keyParts []string) {
if p.Account != nil || p.Customer != nil {
body.Add(form.FormatKey(append(keyParts, "object")), "card")
Expand Down
10 changes: 5 additions & 5 deletions charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
// ChargeFraudUserReport is the list of allowed values for reporting fraud.
type ChargeFraudUserReport string

// List of values that ChargeFraudUserReport can take.
const (
ChargeFraudUserReportFraudulent ChargeFraudUserReport = "fraudulent"
ChargeFraudUserReportSafe ChargeFraudUserReport = "safe"
Expand All @@ -15,6 +16,7 @@ const (
// ChargeFraudStripeReport is the list of allowed values for reporting fraud.
type ChargeFraudStripeReport string

// List of values that ChargeFraudStripeReport can take.
const (
ChargeFraudStripeReportFraudulent ChargeFraudStripeReport = "fraudulent"
)
Expand All @@ -40,7 +42,6 @@ type ChargeLevel3Params struct {
}

// ChargeParams is the set of parameters that can be used when creating or updating a charge.
// For more details see https://stripe.com/docs/api#create_charge and https://stripe.com/docs/api#update_charge.
type ChargeParams struct {
Params `form:"*"`
Amount *int64 `form:"amount"`
Expand Down Expand Up @@ -78,6 +79,7 @@ func (p *ChargeParams) SetSource(sp interface{}) error {
return err
}

// DestinationParams describes the parameters available for the destination hash when creating a charge.
type DestinationParams struct {
Account *string `form:"account"`
Amount *int64 `form:"amount"`
Expand All @@ -89,7 +91,6 @@ type FraudDetailsParams struct {
}

// ChargeListParams is the set of parameters that can be used when listing charges.
// For more details see https://stripe.com/docs/api#list_charges.
type ChargeListParams struct {
ListParams `form:"*"`
Created *int64 `form:"created"`
Expand All @@ -99,7 +100,6 @@ type ChargeListParams struct {
}

// CaptureParams is the set of parameters that can be used when capturing a charge.
// For more details see https://stripe.com/docs/api#charge_capture.
type CaptureParams struct {
Params `form:"*"`
Amount *int64 `form:"amount"`
Expand All @@ -109,7 +109,7 @@ type CaptureParams struct {
StatementDescriptor *string `form:"statement_descriptor"`
}

// ChargeLevel3LineItems represents a line item on level III data.
// ChargeLevel3LineItem represents a line item on level III data.
// This is in private beta and would be empty for most integrations
type ChargeLevel3LineItem struct {
DiscountAmount int64 `json:"discount_amount"`
Expand Down Expand Up @@ -229,7 +229,7 @@ type ShippingDetails struct {
TrackingNumber string `json:"tracking_number"`
}

var depth int = -1
var depth = -1

// UnmarshalJSON handles deserialization of a ChargeOutcomeRule.
// This custom unmarshaling is needed because the resulting
Expand Down
Loading