Skip to content

Commit 238a22b

Browse files
chore(deps): update dependency golangci/golangci-lint to v2 (#1156)
1 parent 9decd0a commit 238a22b

File tree

8 files changed

+60
-45
lines changed

8 files changed

+60
-45
lines changed

.golangci.yml

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
1+
version: "2"
2+
linters:
3+
enable:
4+
- misspell
5+
- revive
6+
- whitespace
7+
exclusions:
8+
generated: lax
9+
presets:
10+
- comments
11+
- common-false-positives
12+
- legacy
13+
- std-error-handling
14+
rules:
15+
- linters:
16+
- dupl
17+
- errcheck
18+
- gocyclo
19+
path: _test\.go
20+
- linters:
21+
- gocyclo
22+
path: pkg/models/envelope.go
23+
text: func `\(Envelope\).Balance`
24+
- linters:
25+
- gocyclo
26+
path: pkg/importer/parser/ynab4/parse.go
27+
text: func `parseTransactions`
28+
paths:
29+
- third_party$
30+
- builtin$
31+
- examples$
132
issues:
233
fix: true
3-
4-
# Relax rules for tests
5-
exclude-rules:
6-
- path: _test\.go
7-
linters:
8-
- gocyclo
9-
- errcheck
10-
- dupl
11-
12-
- path: pkg/models/envelope.go
13-
linters:
14-
- gocyclo
15-
text: "func `\\(Envelope\\).Balance`"
16-
17-
- path: pkg/importer/parser/ynab4/parse.go
18-
linters:
19-
- gocyclo
20-
text: "func `parseTransactions`"
21-
22-
linters:
34+
formatters:
2335
enable:
2436
- gofumpt
2537
- goimports
26-
- govet
27-
- revive
28-
- whitespace
29-
- misspell
30-
31-
linters-settings:
32-
gofumpt:
33-
extra-rules: true
38+
settings:
39+
gofumpt:
40+
extra-rules: true
41+
exclusions:
42+
generated: lax

.pre-commit-config.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,28 @@ repos:
3131
language: system
3232
pass_filenames: false
3333
entry: swag fmt
34-
files: ^pkg/.*
34+
files: ^(pkg|internal)/.*
3535

3636
- id: swag init
3737
name: Create swagger docs.go
3838
language: system
3939
pass_filenames: false
4040
entry: swag init --parseDependency --output ./api
41-
files: ^pkg/.*
41+
files: ^(pkg|internal)/.*
42+
43+
- id: go mod tidy
44+
name: go mod tidy
45+
language: system
46+
pass_filenames: false
47+
entry: go mod tidy
48+
files: ^go\.(mod|sum)$
49+
50+
- id: golangci-lint
51+
name: golangci-lint
52+
language: system
53+
pass_filenames: false
54+
entry: golangci-lint run
55+
files: ^.*\.go$
4256

4357
# Taken from https://github.com/rstcheck/rstcheck/blob/178e8c1001aebe2dcbf006e7e6980246704d2315/.pre-commit-config.yaml#L141
4458
#
@@ -52,11 +66,3 @@ repos:
5266
# This contains "FIMXE" because I often mistype it
5367
entry: '(^|//!?|#|<!--|;|/\*(\*|!)?|\.\.)\s*(FIXME:|FIMXE:|BUG:)(?!#i#)'
5468
exclude: CONTRIBUTING.md
55-
56-
- repo: https://github.com/dnephin/pre-commit-golang
57-
rev: v0.5.1
58-
hooks:
59-
- id: go-mod-tidy
60-
- id: golangci-lint
61-
args:
62-
- "--timeout=5m"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: setup-pre-commit-ci
22
setup-pre-commit-ci:
33
# renovate: datasource=github-releases depName=golangci/golangci-lint
4-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
4+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
55
# renovate: datasource=github-releases depName=swaggo/swag
66
go install github.com/swaggo/swag/cmd/[email protected]
77

internal/controllers/v4/month_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
func (suite *TestSuiteStandard) TestMonthsGet() {
2020
budget := createTestBudget(suite.T(), v4.BudgetEditable{})
2121

22-
r := test.Request(suite.T(), http.MethodGet, strings.Replace(budget.Data.Links.Month, "YYYY-MM", "2022-01", -1), "")
22+
r := test.Request(suite.T(), http.MethodGet, strings.ReplaceAll(budget.Data.Links.Month, "YYYY-MM", "2022-01"), "")
2323
test.AssertHTTPStatus(suite.T(), &r, http.StatusOK)
2424
}
2525

internal/importer/creator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func Create(db *gorm.DB, resources ParsedResources) (models.Budget, error) {
4444
return models.Budget{}, fmt.Errorf("the account '%s' specified in the Match Rule matching '%s' could not be found in the list of Accounts", matchRule.Account, matchRule.Match)
4545
}
4646

47-
matchRule.MatchRule.AccountID = resources.Accounts[aIdx].ID
47+
matchRule.AccountID = resources.Accounts[aIdx].ID
4848

4949
err := tx.Create(&matchRule.MatchRule).Error
5050
if err != nil {

internal/importer/parser/ynab-import/parse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func Parse(f io.Reader, account models.Account) ([]importer.TransactionPreview,
7272
} else if record[headers["Outflow"]] == "" && record[headers["Inflow"]] == "" {
7373
return csvReadError(reader, errors.New("no amount is set for the transaction"))
7474
} else if record[headers["Outflow"]] != "" {
75-
t.Transaction.SourceAccountID = account.DefaultModel.ID
75+
t.Transaction.SourceAccountID = account.ID
7676
t.DestinationAccountName = record[headers["Payee"]]
7777

7878
amount, err := decimal.NewFromString(record[headers["Outflow"]])
@@ -82,7 +82,7 @@ func Parse(f io.Reader, account models.Account) ([]importer.TransactionPreview,
8282

8383
t.Transaction.Amount = amount
8484
} else {
85-
t.Transaction.DestinationAccountID = account.DefaultModel.ID
85+
t.Transaction.DestinationAccountID = account.ID
8686
t.SourceAccountName = record[headers["Payee"]]
8787

8888
amount, err := decimal.NewFromString(record[headers["Inflow"]])

internal/importer/parser/ynab4/parse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func testTransactions(t *testing.T, accounts []models.Account, envelopes []model
332332
for _, tt := range tests {
333333
t.Run(fmt.Sprintf("%s: %s -> %s - %s", tt.date, tt.sourceAccount, tt.destinationAccount, tt.note), func(t *testing.T) {
334334
// Get transaction
335-
idx := slices.IndexFunc(transactions, func(t models.Transaction) bool { return t.Date == tt.date && t.Note == tt.note })
335+
idx := slices.IndexFunc(transactions, func(t models.Transaction) bool { return t.Date.Equal(tt.date) && t.Note == tt.note })
336336
require.NotEqual(t, -1, idx, "No transaction at expected date with expected note")
337337
tr := transactions[idx]
338338

internal/uuid/uuid_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestUnmarshalParam(t *testing.T) {
2828
// A valid UUID in a string parses
2929
id := uuid.NewString()
3030
assert.Nil(t, u.UnmarshalParam(id))
31-
assert.Equal(t, id, u.UUID.String())
31+
assert.Equal(t, id, u.String())
3232

3333
// Empty string parses to Nil UIID
3434
id = ""

0 commit comments

Comments
 (0)