Skip to content

Commit 83963af

Browse files
authored
Upgrade to golangci-lint v2 (#10)
Golangci-lint v2 was released earlier this week [1]. The main River project has already been updated [2], so here we're just going through and updating all the peripheral projects as well. I'm reusing the same `.golangci.yaml` across all of them so that we stay reasonable standardized. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/ [2] riverqueue/river#818
1 parent 85aad90 commit 83963af

2 files changed

Lines changed: 93 additions & 69 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
golangci-lint:
3030
runs-on: ubuntu-latest
3131
env:
32-
GOLANGCI_LINT_VERSION: v1.64.6
32+
GOLANGCI_LINT_VERSION: v2.0.0
3333

3434
steps:
3535
- name: Checkout
@@ -42,6 +42,6 @@ jobs:
4242
go-version-file: "go.mod"
4343

4444
- name: Lint
45-
uses: golangci/golangci-lint-action@v6
45+
uses: golangci/golangci-lint-action@v7
4646
with:
4747
version: ${{ env.GOLANGCI_LINT_VERSION }}

.golangci.yaml

Lines changed: 91 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
issues:
2-
exclude:
3-
- 'Error return value of .(\w+\.Rollback(.*)). is not checked'
1+
version: "2"
42

53
linters:
6-
presets:
7-
- bugs
8-
- comment
9-
- format
10-
- performance
11-
- style
12-
- test
13-
- unused
4+
default: all
145

156
disable:
167
# disabled, but which we should enable with discussion
@@ -21,76 +12,109 @@ linters:
2112
- testpackage # requires tests in test packages like `river_test`
2213

2314
# disabled because they're annoying/bad
15+
- cyclop # screams into the void at "cyclomatic complexity"
16+
- funlen # screams when functions are more than 60 lines long; what are we even doing here guys
2417
- interfacebloat # we do in fact want >10 methods on the Adapter interface or wherever we see fit.
18+
- gocognit # yells that "cognitive complexity" is too high; why
19+
- gocyclo # ANOTHER "cyclomatic complexity" checker (see also "cyclop" and "gocyclo")
2520
- godox # bans TODO statements; total non-starter at the moment
2621
- err113 # wants all errors to be defined as variables at the package level; quite obnoxious
22+
- maintidx # ANOTHER ANOTHER "cyclomatic complexity" lint (see also "cyclop" and "gocyclo")
2723
- mnd # detects "magic numbers", which it defines as any number; annoying
24+
- nestif # yells when if blocks are nested; what planet do these people come from?
2825
- ireturn # bans returning interfaces; questionable as is, but also buggy as hell; very, very annoying
2926
- lll # restricts maximum line length; annoying
3027
- nlreturn # requires a blank line before returns; annoying
3128
- wsl # a bunch of style/whitespace stuff; annoying
3229

33-
linters-settings:
34-
depguard:
35-
rules:
36-
all:
37-
files: ["$all"]
38-
deny:
39-
- desc: "Use `github.com/google/uuid` package for UUIDs instead."
40-
pkg: "github.com/xtgo/uuid"
30+
settings:
31+
depguard:
32+
rules:
33+
all:
34+
files: ["$all"]
35+
deny:
36+
- desc: Use `github.com/google/uuid` package for UUIDs instead.
37+
pkg: github.com/xtgo/uuid
38+
not-test:
39+
files: ["!$test"]
40+
deny:
41+
- desc: Don't use `dbadaptertest` package outside of test environments.
42+
pkg: github.com/riverqueue/river/internal/dbadaptertest
43+
- desc: Don't use `riverinternaltest` package outside of test environments.
44+
pkg: github.com/riverqueue/river/internal/riverinternaltest
4145

42-
forbidigo:
43-
forbid:
44-
- msg: "Use `require` variants instead."
45-
p: '^assert\.'
46-
- msg: "Use `Func` suffix for function variables instead."
47-
p: 'Fn\b'
48-
- msg: "Use built-in `max` function instead."
49-
p: '\bmath\.Max\b'
50-
- msg: "Use built-in `min` function instead."
51-
p: '\bmath\.Min\b'
46+
forbidigo:
47+
forbid:
48+
- msg: Use `require` variants instead.
49+
pattern: ^assert\.
50+
- msg: Use `Func` suffix for function variables instead.
51+
pattern: Fn\b
52+
- msg: Use built-in `max` function instead.
53+
pattern: \bmath\.Max\b
54+
- msg: Use built-in `min` function instead.
55+
pattern: \bmath\.Min\b
5256

53-
gci:
54-
sections:
55-
- Standard
56-
- Default
57-
- Prefix(github.com/riverqueue)
57+
gomoddirectives:
58+
replace-local: true
5859

59-
gomoddirectives:
60-
replace-local: true
60+
gosec:
61+
excludes:
62+
- G404 # use of non-crypto random; overly broad for our use case
6163

62-
gosec:
63-
excludes:
64-
- G404 # use of non-crypto random; overly broad for our use case
64+
revive:
65+
rules:
66+
- name: unused-parameter
67+
disabled: true
6568

66-
revive:
67-
rules:
68-
- name: unused-parameter
69-
disabled: true
69+
tagliatelle:
70+
case:
71+
rules:
72+
json: snake
7073

71-
tagliatelle:
72-
case:
73-
rules:
74-
json: snake
74+
testifylint:
75+
enable-all: true
76+
disable:
77+
- go-require
78+
79+
varnamelen:
80+
ignore-names:
81+
- db
82+
- eg
83+
- f
84+
- i
85+
- id
86+
- j
87+
- mu
88+
- r
89+
- sb # common convention for string builder
90+
- t
91+
- tt # common convention for table tests
92+
- tx
93+
- w
94+
- wg
95+
96+
exclusions:
97+
generated: lax
98+
presets:
99+
- comments
100+
- common-false-positives
101+
- legacy
102+
- std-error-handling
103+
rules:
104+
- path: (.+)\.go$
105+
text: Error return value of .(\w+\.Rollback(.*)). is not checked
75106

76-
testifylint:
77-
enable-all: true
78-
disable:
79-
- go-require
107+
formatters:
108+
enable:
109+
- gci
110+
- gofmt
111+
- gofumpt
112+
- goimports
80113

81-
varnamelen:
82-
ignore-names:
83-
- db
84-
- eg
85-
- f
86-
- i
87-
- id
88-
- j
89-
- mu
90-
- r
91-
- sb # common convention for string builder
92-
- t
93-
- tt # common convention for table tests
94-
- tx
95-
- w
96-
- wg
114+
settings:
115+
gci:
116+
sections:
117+
- Standard
118+
- Default
119+
- Prefix(github.com/riverqueue)
120+
- Prefix(riverqueue.com/riverpro)

0 commit comments

Comments
 (0)