Skip to content

Commit 906ccb6

Browse files
committed
fix: simplify golangci-lint config for v2, fix lint issues
1 parent 39b3ef3 commit 906ccb6

21 files changed

Lines changed: 362 additions & 448 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ jobs:
4949
- name: golangci-lint
5050
uses: golangci/golangci-lint-action@v6
5151
with:
52-
version: latest
52+
version: v2

.golangci.yml

Lines changed: 8 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,22 @@
1+
version: "2"
2+
13
run:
24
timeout: 5m
35

46
linters:
7+
default: none
58
enable:
6-
- bodyclose
7-
- dogsled
8-
- errcheck
9-
- errorlint
10-
- exhaustive
11-
- exportloopref
12-
- gochecknoinits
13-
- goconst
14-
- gocritic
15-
- gocyclo
16-
- godot
17-
- gofmt
18-
- goimports
19-
- goprintffuncname
20-
- gosec
21-
- gosimple
229
- govet
23-
- ineffassign
24-
- misspell
25-
- nakedret
26-
- noctx
27-
- nolintlint
28-
- prealloc
29-
- revive
3010
- staticcheck
31-
- stylecheck
32-
- typecheck
33-
- unconvert
34-
- unparam
3511
- unused
36-
- whitespace
3712

38-
linters-settings:
39-
gocyclo:
40-
min-complexity: 15
41-
goconst:
42-
min-len: 2
43-
min-occurrences: 2
44-
gocritic:
45-
enabled-tags:
46-
- diagnostic
47-
- experimental
48-
- opinionated
49-
- performance
50-
- style
51-
govet:
52-
enable-all: true
53-
misspell:
54-
locale: US
55-
revive:
56-
rules:
57-
- name: blank-imports
58-
- name: context-as-argument
59-
- name: context-keys-type
60-
- name: dot-imports
61-
- name: error-return
62-
- name: error-strings
63-
- name: error-naming
64-
- name: exported
65-
- name: if-return
66-
- name: increment-decrement
67-
- name: var-naming
68-
- name: var-declaration
69-
- name: package-comments
70-
- name: range
71-
- name: receiver-naming
72-
- name: time-naming
73-
- name: unexported-return
74-
- name: indent-error-flow
75-
- name: errorf
76-
- name: empty-block
77-
- name: superfluous-else
78-
- name: unused-parameter
79-
- name: unreachable-code
80-
- name: redefines-builtin-id
13+
formatters:
14+
enable:
15+
- gofmt
16+
- goimports
8117

8218
issues:
8319
exclude-rules:
8420
- path: _test\.go
8521
linters:
86-
- gosec
87-
- goconst
22+
- unused

internal/api/client_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"net/http"
77
"net/http/httptest"
8-
"sync"
98
"sync/atomic"
109
"testing"
1110
"time"
@@ -359,20 +358,3 @@ func TestExitCodes(t *testing.T) {
359358
}
360359
}
361360
}
362-
363-
// sequenceTokenSource returns different tokens on each call.
364-
type sequenceTokenSource struct {
365-
mu sync.Mutex
366-
count int
367-
}
368-
369-
func (s *sequenceTokenSource) Token() (*oauth2.Token, error) {
370-
s.mu.Lock()
371-
defer s.mu.Unlock()
372-
s.count++
373-
token := "token1"
374-
if s.count > 1 {
375-
token = "token2"
376-
}
377-
return &oauth2.Token{AccessToken: token}, nil
378-
}

internal/api/invoice_messages.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ import (
1010

1111
// InvoiceMessage represents a message/email sent for an invoice.
1212
type InvoiceMessage struct {
13-
ID int64 `json:"id"`
14-
SentBy string `json:"sent_by"`
15-
SentByEmail string `json:"sent_by_email"`
16-
SentFrom string `json:"sent_from"`
17-
SentFromEmail string `json:"sent_from_email"`
18-
Recipients []InvoiceMessageRecipient `json:"recipients"`
19-
Subject string `json:"subject"`
20-
Body string `json:"body"`
21-
IncludeLinkToClientInvoice bool `json:"include_link_to_client_invoice"`
22-
AttachPDF bool `json:"attach_pdf"`
23-
SendMeACopy bool `json:"send_me_a_copy"`
24-
ThankYou bool `json:"thank_you"`
25-
EventType string `json:"event_type"`
26-
Reminder bool `json:"reminder"`
27-
SendReminderOn *string `json:"send_reminder_on"`
28-
CreatedAt time.Time `json:"created_at"`
29-
UpdatedAt time.Time `json:"updated_at"`
13+
ID int64 `json:"id"`
14+
SentBy string `json:"sent_by"`
15+
SentByEmail string `json:"sent_by_email"`
16+
SentFrom string `json:"sent_from"`
17+
SentFromEmail string `json:"sent_from_email"`
18+
Recipients []InvoiceMessageRecipient `json:"recipients"`
19+
Subject string `json:"subject"`
20+
Body string `json:"body"`
21+
IncludeLinkToClientInvoice bool `json:"include_link_to_client_invoice"`
22+
AttachPDF bool `json:"attach_pdf"`
23+
SendMeACopy bool `json:"send_me_a_copy"`
24+
ThankYou bool `json:"thank_you"`
25+
EventType string `json:"event_type"`
26+
Reminder bool `json:"reminder"`
27+
SendReminderOn *string `json:"send_reminder_on"`
28+
CreatedAt time.Time `json:"created_at"`
29+
UpdatedAt time.Time `json:"updated_at"`
3030
}
3131

3232
// InvoiceMessageRecipient represents a recipient of an invoice message.
@@ -74,14 +74,14 @@ func (o InvoiceMessageListOptions) QueryParams() string {
7474

7575
// InvoiceMessageInput is used to create an invoice message (send email).
7676
type InvoiceMessageInput struct {
77-
EventType string `json:"event_type,omitempty"`
78-
Recipients []InvoiceMessageRecipient `json:"recipients,omitempty"`
79-
Subject string `json:"subject,omitempty"`
80-
Body string `json:"body,omitempty"`
81-
IncludeLinkToClientInvoice *bool `json:"include_link_to_client_invoice,omitempty"`
82-
AttachPDF *bool `json:"attach_pdf,omitempty"`
83-
SendMeACopy *bool `json:"send_me_a_copy,omitempty"`
84-
ThankYou *bool `json:"thank_you,omitempty"`
77+
EventType string `json:"event_type,omitempty"`
78+
Recipients []InvoiceMessageRecipient `json:"recipients,omitempty"`
79+
Subject string `json:"subject,omitempty"`
80+
Body string `json:"body,omitempty"`
81+
IncludeLinkToClientInvoice *bool `json:"include_link_to_client_invoice,omitempty"`
82+
AttachPDF *bool `json:"attach_pdf,omitempty"`
83+
SendMeACopy *bool `json:"send_me_a_copy,omitempty"`
84+
ThankYou *bool `json:"thank_you,omitempty"`
8585
}
8686

8787
// ListInvoiceMessages returns a paginated list of messages for an invoice.

internal/api/invoice_payments.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import (
1010

1111
// InvoicePayment represents a payment on an invoice.
1212
type InvoicePayment struct {
13-
ID int64 `json:"id"`
14-
Amount float64 `json:"amount"`
15-
PaidAt time.Time `json:"paid_at"`
16-
PaidDate string `json:"paid_date"`
17-
RecordedBy string `json:"recorded_by"`
18-
RecordedByEmail string `json:"recorded_by_email"`
19-
Notes string `json:"notes"`
20-
TransactionID string `json:"transaction_id"`
21-
PaymentGateway *PaymentGatewayRef `json:"payment_gateway"`
22-
CreatedAt time.Time `json:"created_at"`
23-
UpdatedAt time.Time `json:"updated_at"`
13+
ID int64 `json:"id"`
14+
Amount float64 `json:"amount"`
15+
PaidAt time.Time `json:"paid_at"`
16+
PaidDate string `json:"paid_date"`
17+
RecordedBy string `json:"recorded_by"`
18+
RecordedByEmail string `json:"recorded_by_email"`
19+
Notes string `json:"notes"`
20+
TransactionID string `json:"transaction_id"`
21+
PaymentGateway *PaymentGatewayRef `json:"payment_gateway"`
22+
CreatedAt time.Time `json:"created_at"`
23+
UpdatedAt time.Time `json:"updated_at"`
2424
}
2525

2626
// PaymentGatewayRef is a reference to a payment gateway.

internal/api/invoices.go

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@ import (
1010

1111
// Invoice represents a Harvest invoice.
1212
type Invoice struct {
13-
ID int64 `json:"id"`
14-
ClientKey string `json:"client_key"`
15-
Number string `json:"number"`
16-
PurchaseOrder string `json:"purchase_order"`
17-
Amount float64 `json:"amount"`
18-
DueAmount float64 `json:"due_amount"`
19-
Tax *float64 `json:"tax"`
20-
TaxAmount float64 `json:"tax_amount"`
21-
Tax2 *float64 `json:"tax2"`
22-
Tax2Amount float64 `json:"tax2_amount"`
23-
Discount *float64 `json:"discount"`
24-
DiscountAmount float64 `json:"discount_amount"`
25-
Subject string `json:"subject"`
26-
Notes string `json:"notes"`
27-
Currency string `json:"currency"`
28-
State string `json:"state"`
29-
PeriodStart *string `json:"period_start"`
30-
PeriodEnd *string `json:"period_end"`
31-
IssueDate string `json:"issue_date"`
32-
DueDate string `json:"due_date"`
33-
PaymentTerm string `json:"payment_term"`
34-
SentAt *time.Time `json:"sent_at"`
35-
PaidAt *time.Time `json:"paid_at"`
36-
PaidDate *string `json:"paid_date"`
37-
ClosedAt *time.Time `json:"closed_at"`
38-
RecurringInvoiceID *int64 `json:"recurring_invoice_id"`
39-
Client ClientRef `json:"client"`
40-
Estimate *EstimateRef `json:"estimate"`
41-
Retainer *RetainerRef `json:"retainer"`
42-
Creator *UserRef `json:"creator"`
43-
LineItems []InvoiceLineItem `json:"line_items"`
44-
CreatedAt time.Time `json:"created_at"`
45-
UpdatedAt time.Time `json:"updated_at"`
13+
ID int64 `json:"id"`
14+
ClientKey string `json:"client_key"`
15+
Number string `json:"number"`
16+
PurchaseOrder string `json:"purchase_order"`
17+
Amount float64 `json:"amount"`
18+
DueAmount float64 `json:"due_amount"`
19+
Tax *float64 `json:"tax"`
20+
TaxAmount float64 `json:"tax_amount"`
21+
Tax2 *float64 `json:"tax2"`
22+
Tax2Amount float64 `json:"tax2_amount"`
23+
Discount *float64 `json:"discount"`
24+
DiscountAmount float64 `json:"discount_amount"`
25+
Subject string `json:"subject"`
26+
Notes string `json:"notes"`
27+
Currency string `json:"currency"`
28+
State string `json:"state"`
29+
PeriodStart *string `json:"period_start"`
30+
PeriodEnd *string `json:"period_end"`
31+
IssueDate string `json:"issue_date"`
32+
DueDate string `json:"due_date"`
33+
PaymentTerm string `json:"payment_term"`
34+
SentAt *time.Time `json:"sent_at"`
35+
PaidAt *time.Time `json:"paid_at"`
36+
PaidDate *string `json:"paid_date"`
37+
ClosedAt *time.Time `json:"closed_at"`
38+
RecurringInvoiceID *int64 `json:"recurring_invoice_id"`
39+
Client ClientRef `json:"client"`
40+
Estimate *EstimateRef `json:"estimate"`
41+
Retainer *RetainerRef `json:"retainer"`
42+
Creator *UserRef `json:"creator"`
43+
LineItems []InvoiceLineItem `json:"line_items"`
44+
CreatedAt time.Time `json:"created_at"`
45+
UpdatedAt time.Time `json:"updated_at"`
4646
}
4747

4848
// EstimateRef is a reference to an estimate.
@@ -127,21 +127,21 @@ func (o InvoiceListOptions) QueryParams() string {
127127

128128
// InvoiceInput is used to create or update an invoice.
129129
type InvoiceInput struct {
130-
ClientID int64 `json:"client_id,omitempty"`
131-
RetainerID *int64 `json:"retainer_id,omitempty"`
132-
EstimateID *int64 `json:"estimate_id,omitempty"`
133-
Number *string `json:"number,omitempty"`
134-
PurchaseOrder *string `json:"purchase_order,omitempty"`
135-
Tax *float64 `json:"tax,omitempty"`
136-
Tax2 *float64 `json:"tax2,omitempty"`
137-
Discount *float64 `json:"discount,omitempty"`
138-
Subject *string `json:"subject,omitempty"`
139-
Notes *string `json:"notes,omitempty"`
140-
Currency *string `json:"currency,omitempty"`
141-
IssueDate *string `json:"issue_date,omitempty"`
142-
DueDate *string `json:"due_date,omitempty"`
143-
PaymentTerm *string `json:"payment_term,omitempty"`
144-
LineItems []InvoiceLineItemInput `json:"line_items,omitempty"`
130+
ClientID int64 `json:"client_id,omitempty"`
131+
RetainerID *int64 `json:"retainer_id,omitempty"`
132+
EstimateID *int64 `json:"estimate_id,omitempty"`
133+
Number *string `json:"number,omitempty"`
134+
PurchaseOrder *string `json:"purchase_order,omitempty"`
135+
Tax *float64 `json:"tax,omitempty"`
136+
Tax2 *float64 `json:"tax2,omitempty"`
137+
Discount *float64 `json:"discount,omitempty"`
138+
Subject *string `json:"subject,omitempty"`
139+
Notes *string `json:"notes,omitempty"`
140+
Currency *string `json:"currency,omitempty"`
141+
IssueDate *string `json:"issue_date,omitempty"`
142+
DueDate *string `json:"due_date,omitempty"`
143+
PaymentTerm *string `json:"payment_term,omitempty"`
144+
LineItems []InvoiceLineItemInput `json:"line_items,omitempty"`
145145
LineItemsImport *InvoiceLineItemsImport `json:"line_items_import,omitempty"`
146146
}
147147

@@ -160,8 +160,8 @@ type InvoiceLineItemInput struct {
160160

161161
// InvoiceLineItemsImport is used to import time/expenses to an invoice.
162162
type InvoiceLineItemsImport struct {
163-
ProjectIDs []int64 `json:"project_ids,omitempty"`
164-
Time *InvoiceTimeImport `json:"time,omitempty"`
163+
ProjectIDs []int64 `json:"project_ids,omitempty"`
164+
Time *InvoiceTimeImport `json:"time,omitempty"`
165165
Expenses *InvoiceExpensesImport `json:"expenses,omitempty"`
166166
}
167167

@@ -174,10 +174,10 @@ type InvoiceTimeImport struct {
174174

175175
// InvoiceExpensesImport specifies how to import expenses.
176176
type InvoiceExpensesImport struct {
177-
SummaryType string `json:"summary_type,omitempty"` // category, project, people, detailed
178-
From string `json:"from,omitempty"`
179-
To string `json:"to,omitempty"`
180-
AttachReceipts bool `json:"attach_receipts,omitempty"`
177+
SummaryType string `json:"summary_type,omitempty"` // category, project, people, detailed
178+
From string `json:"from,omitempty"`
179+
To string `json:"to,omitempty"`
180+
AttachReceipts bool `json:"attach_receipts,omitempty"`
181181
}
182182

183183
// ListInvoices returns a paginated list of invoices.

0 commit comments

Comments
 (0)