Skip to content

Commit 43cac6f

Browse files
authored
chore: upgrade golangci-lint to v2 (#305)
* chore: upgrade `golangci-lint` to v2 * chore: migrate linter config * chore: restore comments * chore: update disable comment * chore: update to v2.1.6 * chore: disable staticcheck violation for now * ci: bump this version too
1 parent b4ad2af commit 43cac6f

File tree

5 files changed

+71
-49
lines changed

5 files changed

+71
-49
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ jobs:
4444
go-version-file: .go-version
4545

4646
- name: Run golangci-lint
47-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
47+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
4848
with:
49-
version: v1.64
49+
version: v2.1
5050
go-fmt:
5151
permissions:
5252
contents: read # to fetch code (actions/checkout)

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343
go-version-file: .go-version
4444

4545
- name: Run golangci-lint
46-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
46+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
4747
with:
48-
version: v1.64
48+
version: v2.1
4949
go-fmt:
5050
permissions:
5151
contents: read # to fetch code (actions/checkout)

.golangci.yaml

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,72 @@
1-
output:
2-
sort-results: true
1+
version: '2'
32
linters:
4-
enable-all: true
3+
default: all
54
# prettier-ignore
65
disable:
7-
- cyclop
8-
- exhaustruct # overkill
9-
- forcetypeassert # too hard
10-
- funlen
11-
- gocognit
12-
- gocyclo
13-
- godot # comments are fine without full stops
14-
- godox # to-do comments are fine
15-
- maintidx
16-
- gofumpt
17-
- ireturn # disagree with, sort of
18-
- lll # line length is hard
19-
- mnd # not every number is magic
20-
- nestif
21-
- nonamedreturns # they have their uses
22-
- tagliatelle # we're parsing data from external sources
23-
- tenv # Deprecated
24-
- varnamelen # maybe later
25-
- wsl # disagree with, for now
26-
27-
linters-settings:
28-
depguard:
6+
- cyclop #
7+
- exhaustruct # overkill
8+
- forcetypeassert # too hard
9+
- funcorder #
10+
- funlen #
11+
- gocognit #
12+
- gocyclo #
13+
- godot # comments are fine without full stops
14+
- godox # to-do comments are fine
15+
- ireturn # disagree with, sort of
16+
- lll #
17+
- maintidx #
18+
- mnd # not every number is magic
19+
- nestif #
20+
- nonamedreturns # they have their uses
21+
- tagliatelle # we're parsing data from external sources
22+
- varnamelen # maybe later
23+
- wsl # disagree with, for now
24+
settings:
25+
depguard:
26+
rules:
27+
regexp:
28+
files:
29+
- '!**/internal/cachedregexp/**'
30+
- '!**/main_test.go'
31+
deny:
32+
- pkg: regexp
33+
desc:
34+
Use github.com/g-rath/osv-detector/internal/cachedregexp instead
35+
staticcheck:
36+
checks:
37+
- all
38+
- -QF1006 # lift into loop condition
39+
exclusions:
40+
generated: lax
41+
presets:
42+
- comments
43+
- common-false-positives
44+
- legacy
45+
- std-error-handling
2946
rules:
30-
regexp:
31-
files:
32-
- '!**/internal/cachedregexp/**'
33-
- '!**/main_test.go'
34-
deny:
35-
- pkg: 'regexp'
36-
desc:
37-
'Use github.com/g-rath/osv-detector/internal/cachedregexp instead'
38-
47+
- linters:
48+
- dupl
49+
- err113
50+
- goconst
51+
path: _test\.go
52+
- linters:
53+
- gochecknoglobals
54+
path: main.go
55+
paths:
56+
- third_party$
57+
- builtin$
58+
- examples$
3959
issues:
4060
max-issues-per-linter: 0
4161
max-same-issues: 0
42-
exclude-rules:
43-
- path: _test\.go
44-
linters:
45-
- goconst
46-
- goerr113
47-
- dupl
48-
- path: main.go
49-
linters:
50-
- gochecknoglobals
62+
formatters:
63+
enable:
64+
- gci
65+
- gofmt
66+
- goimports
67+
exclusions:
68+
generated: lax
69+
paths:
70+
- third_party$
71+
- builtin$
72+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test-with-coverage:
2121
lint: lint-with-golangci-lint lint-with-go-fmt
2222

2323
lint-with-golangci-lint:
24-
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 run ./...
24+
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run ./...
2525

2626
lint-with-go-fmt:
2727
gofmt -s -d */**.go

pkg/lockfile/parse-gradle-lock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func isNotGradleDependencyLine(line string) bool {
1414
func parseGradleLine(line string) (PackageDetails, error) {
1515
parts := strings.SplitN(line, ":", 3)
1616
if len(parts) < 3 {
17-
return PackageDetails{}, fmt.Errorf("invalid line in gradle lockfile: %s", line) //nolint:goerr113
17+
return PackageDetails{}, fmt.Errorf("invalid line in gradle lockfile: %s", line) //nolint:err113
1818
}
1919

2020
group, artifact, version := parts[0], parts[1], parts[2]

0 commit comments

Comments
 (0)