Skip to content

Commit 01d331b

Browse files
committed
refactor: update to golangci-lint v2.0.2
This change updates to the latest golangci-lint, revisits the linters being used, and addresses any reported issues from those linters. Signed-off-by: m-d-key <[email protected]>
1 parent b2b3f25 commit 01d331b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+429
-766
lines changed

.bingo/Variables.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ $(GIT_CHGLOG): $(BINGO_DIR)/git-chglog.mod
2323
@echo "(re)installing $(GOBIN)/git-chglog-v0.15.4"
2424
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=git-chglog.mod -o=$(GOBIN)/git-chglog-v0.15.4 "github.com/git-chglog/git-chglog/cmd/git-chglog"
2525

26-
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.63.4
26+
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.0.2
2727
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
2828
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
29-
@echo "(re)installing $(GOBIN)/golangci-lint-v1.63.4"
30-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.63.4 "github.com/golangci/golangci-lint/cmd/golangci-lint"
29+
@echo "(re)installing $(GOBIN)/golangci-lint-v2.0.2"
30+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v2.0.2 "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"
3131

3232
GOTAGGER := $(GOBIN)/gotagger-v0.9.1
3333
$(GOTAGGER): $(BINGO_DIR)/gotagger.mod

.bingo/golangci-lint.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.22.4
3+
go 1.23.5
44

5-
require github.com/golangci/golangci-lint v1.63.4 // cmd/golangci-lint
5+
require github.com/golangci/golangci-lint/v2 v2.0.2 // cmd/golangci-lint

.bingo/golangci-lint.sum

Lines changed: 147 additions & 463 deletions
Large diffs are not rendered by default.

.bingo/variables.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010

1111
GIT_CHGLOG="${GOBIN}/git-chglog-v0.15.4"
1212

13-
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.63.4"
13+
GOLANGCI_LINT="${GOBIN}/golangci-lint-v2.0.2"
1414

1515
GOTAGGER="${GOBIN}/gotagger-v0.9.1"
1616

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
go-version: stable
2323

2424
- name: Lint with golangci-lint
25-
uses: golangci/golangci-lint-action@v6.5.2
25+
uses: golangci/golangci-lint-action@v7.0.0

.golangci.yml

Lines changed: 80 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,103 @@
1+
version: "2"
12
linters:
2-
disable-all: true
3+
default: none
34
enable:
5+
- asasalint
6+
- asciicheck
7+
- bidichk
48
- bodyclose
9+
- canonicalheader
10+
- containedctx
11+
- contextcheck
12+
- copyloopvar
13+
- cyclop
14+
- decorder
515
- dogsled
616
- dupl
17+
- durationcheck
718
- errcheck
19+
- errchkjson
20+
- errname
21+
- errorlint
22+
- exptostd
23+
- fatcontext
24+
- forbidigo
25+
- forcetypeassert
826
- funlen
27+
- ginkgolinter
28+
- gocheckcompilerdirectives
929
- gochecknoinits
30+
- gochecksumtype
31+
- gocognit
1032
- goconst
1133
- gocritic
1234
- gocyclo
13-
- gofmt
14-
- goimports
35+
- godot
36+
- godox
37+
- goheader
38+
- gomoddirectives
39+
- gomodguard
40+
- goprintffuncname
1541
- gosec
16-
- gosimple
42+
- gosmopolitan
1743
- govet
44+
- grouper
45+
- iface
46+
- importas
47+
- inamedparam
1848
- ineffassign
49+
- intrange
1950
- lll
51+
- loggercheck
52+
- maintidx
53+
- makezero
54+
- mirror
2055
- misspell
56+
- musttag
2157
- nakedret
58+
- nestif
59+
- nilerr
60+
- nilnesserr
61+
- nilnil
62+
- noctx
63+
- nosprintfhostport
64+
- perfsprint
65+
- prealloc
66+
- predeclared
67+
- promlinter
68+
- protogetter
69+
- reassign
70+
- recvcheck
71+
- revive
72+
- rowserrcheck
73+
- sloglint
74+
- spancheck
75+
- sqlclosecheck
2276
- staticcheck
23-
- stylecheck
24-
# TODO: Add linter back when support for generics is available.
25-
# ref: https://github.com/golangci/golangci-lint/issues/2649
26-
- typecheck
27-
# TODO: Add linter back when support for generics is available.
28-
# ref: https://github.com/golangci/golangci-lint/issues/2649
77+
- tagalign
78+
- tagliatelle
79+
- testableexamples
80+
- testifylint
81+
- testpackage
82+
- tparallel
2983
- unconvert
30-
# TODO: Add linter back when support for generics is available.
31-
# ref: https://github.com/golangci/golangci-lint/issues/2649
3284
- unparam
3385
- unused
34-
# TODO: Add linter back when support for generics is available.
35-
# ref: https://github.com/golangci/golangci-lint/issues/2649
86+
- usestdlibvars
87+
- usetesting
88+
- wastedassign
3689
- whitespace
90+
- zerologlint
91+
exclusions:
92+
presets:
93+
- common-false-positives
94+
rules:
95+
- linters:
96+
- goconst
97+
- forbidigo
98+
path: (.+)_test\.go
99+
formatters:
100+
enable:
101+
- gofmt
102+
- goimports
37103

38-
#run:
39-
# go: "1.22"
40-
# timeout: 10m
41-
linters-settings:
42-
goconst:
43-
ignore-tests: true
44-
# golint:
45-
# min-confidence: 0
46-
# lll:
47-
# line-length: 160
48-
# gocritic:
49-
# # Note that the following checks are the default checks,
50-
# # plus builtinShadow. They are ordered as they appear on
51-
# # the explanation page, grouped by the type of check.
52-
# # Ref: https://go-critic.github.io/overview.html
53-
# enabled-checks:
54-
# # Diagnostic checks
55-
# - appendAssign
56-
# - caseOrder
57-
# - dupArg
58-
# - dupBranchBody
59-
# - dupCase
60-
# - dupSubExpr
61-
# - flagDeref
62-
# # Style checks
63-
# - assignOp
64-
# - builtinShadow
65-
# - captLocal
66-
# - defaultCaseOrder
67-
# - elseif
68-
# - ifElseChain
69-
# - regexpMust
70-
# - singleCaseSwitch
71-
# - sloppyLen
72-
# - switchTrue
73-
# - typeSwitchVar
74-
# - underef
75-
# - unlambda
76-
# - unslice
77-
# govet:
78-
# # report about shadowed variables
79-
# check-shadowing: true
80-
#
81-
#
82-
#issues:
83-
# exclude-use-default: false
84-
# exclude-rules:
85-
# - path: pkg/di/doc.go
86-
# linters:
87-
# - gofmt
88-
# - goimports
89-
# - path: pkg/memoize/doc.go
90-
# linters:
91-
# - gofmt
92-
# - goimports
93-
# - path: pkg/maybe/doc.go
94-
# linters:
95-
# - gofmt
96-
# - goimports
97-
# - path: pkg/result/doc.go
98-
# linters:
99-
# - gofmt
100-
# - goimports
101-
# - text: "and that stutters"
102-
# linters:
103-
# - golint
104-
# - text: "error strings should not be capitalized or end with punctuation or a newline"
105-
# linters:
106-
# - golint
107-
# - text: "G101: Potential hardcoded credentials"
108-
# linters:
109-
# - gosec
110-
# - text: "should omit comparison to bool constant"
111-
# linters:
112-
# - gosimple
113-
# - text: "S1023: redundant `return` statement"
114-
# linters:
115-
# - gosimple
116-
# - text: "S1000: should use for range instead of for { select {} }"
117-
# linters:
118-
# - gosimple
119-
# - text: "ST1005: error strings should not be capitalized"
120-
# linters:
121-
# - stylecheck
122-
# - text: "should have a package comment, unless it's in another file for this package"
123-
# linters:
124-
# - golint
125-
# - text: "S1002: should omit comparison to bool constant"
126-
# linters:
127-
# - gosimple
128-
#

internal/constants/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Package constants defines the constants used by the library.
77
package constants
88

99
const (
10-
// AppName is the app name
10+
// AppName is the app name.
1111
AppName = "go-lib"
1212
)

pkg/collections/bag/bag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (bag *Bag[T]) ToSlice() []T {
145145
results := make([]T, 0, size)
146146
content := bag.getContent()
147147
for key, count := range content {
148-
for i := 0; i < count; i++ {
148+
for range count {
149149
results = append(results, key)
150150
}
151151
}

pkg/collections/bag/bag_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Test_Map(t *testing.T) {
3535
func Test_Map_error(t *testing.T) {
3636
colors := bag.NewFrom[string](`red`, `green`, `blue`)
3737
failedMap := `failed MAP`
38-
mapper := func(value string) result.Result[int] {
38+
mapper := func(_ string) result.Result[int] {
3939
return result.Error[int](errors.New(failedMap))
4040
}
4141
actual := bag.Map[string, int](mapper, colors)
@@ -216,7 +216,7 @@ func Test_Bag_Select_error(t *testing.T) {
216216
Add(1, 2)
217217
expectedMessage := `failing SELECT filter `
218218
itemCount := 1
219-
isEvenFilter := func(item int) result.Result[bool] {
219+
isEvenFilter := func(_ int) result.Result[bool] {
220220
if itemCount == 1 {
221221
itemCount++
222222
return result.Ok(true) // Ensure we have some data in the target.

pkg/collections/collections_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Test_Test_Detect(t *testing.T) {
3939
detectAbsent := func(v int) result.Result[bool] {
4040
return result.Ok(v == 2)
4141
}
42-
detectError := func(v int) result.Result[bool] {
42+
detectError := func(_ int) result.Result[bool] {
4343
return result.Error[bool](errors.New("failed"))
4444
}
4545
present := result.FlatMap2(collections.Detect[int], s, result.Ok(filters.Filter[int](detectPresent)))
@@ -75,7 +75,7 @@ func Test_Select(t *testing.T) {
7575
selectAbsent := func(v int) result.Result[bool] {
7676
return result.Ok(v == 100)
7777
}
78-
selectError := func(v int) result.Result[bool] {
78+
selectError := func(_ int) result.Result[bool] {
7979
return result.Error[bool](errors.New("failed"))
8080
}
8181
present := result.FlatMap2(collections.Select[int], s, result.Ok(filters.Filter[int](selectPresent)))

0 commit comments

Comments
 (0)