Skip to content

Commit 994190a

Browse files
committed
Update golangci to v2
Signed-off-by: apostasie <[email protected]>
1 parent ae29b3b commit 994190a

File tree

6 files changed

+234
-184
lines changed

6 files changed

+234
-184
lines changed

.github/workflows/lint.yml

-3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,3 @@ jobs:
7575
run: make lint-yaml
7676
- name: shell
7777
run: make lint-shell
78-
- name: go imports ordering
79-
run: |
80-
make lint-imports

.golangci.yml

+218-152
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,233 @@
1-
---
1+
version: "2"
2+
23
run:
3-
concurrency: 6
4-
timeout: 5m
4+
modules-download-mode: readonly
5+
6+
issues:
7+
max-issues-per-linter: 0
8+
max-same-issues: 0
9+
510
linters:
6-
disable-all: true
11+
default: none
712
enable:
813
- depguard
9-
- gofmt
10-
- goimports
1114
- govet
1215
- ineffassign
1316
- misspell
1417
- nakedret
1518
- prealloc
16-
- typecheck
17-
# - asciicheck
18-
# - bodyclose
19-
# - dogsled
20-
# - dupl
21-
# - errcheck
22-
# - errorlint
23-
# - exhaustive
24-
# - exhaustivestruct
25-
# - exportloopref
26-
# - funlen
27-
# - gci
28-
# - gochecknoglobals
29-
# - gochecknoinits
30-
# - gocognit
31-
# - goconst
32-
# - gocritic
33-
# - gocyclo
34-
# - godot
35-
# - godox
36-
# - goerr113
37-
# - gofumpt
38-
# - goheader
39-
# - golint
40-
# - gomnd
41-
# - gomodguard
42-
# - goprintffuncname
43-
# - gosec (gas)
44-
- gosimple # (megacheck)
45-
# - interfacer
46-
# - lll
47-
# - maligned
48-
# - nestif
49-
# - nlreturn
50-
# - noctx
51-
# - nolintlint
5219
- revive
53-
# - rowserrcheck
54-
# - scopelint
55-
# - sqlclosecheck
5620
- staticcheck
57-
- stylecheck
58-
# - testpackage
59-
# - tparallel
6021
- unconvert
61-
# - unparam
6222
- unused
63-
# - whitespace
64-
# - wrapcheck
65-
# - wsl
66-
linters-settings:
67-
gocritic:
68-
enabled-checks:
69-
# Diagnostic
70-
- appendAssign
71-
- argOrder
72-
- badCond
73-
- caseOrder
74-
- codegenComment
75-
- commentedOutCode
76-
- deprecatedComment
77-
- dupArg
78-
- dupBranchBody
79-
- dupCase
80-
- dupSubExpr
81-
- exitAfterDefer
82-
- flagDeref
83-
- flagName
84-
- nilValReturn
85-
- offBy1
86-
- sloppyReassign
87-
- weakCond
88-
- octalLiteral
89-
90-
# Performance
91-
- appendCombine
92-
- equalFold
93-
- hugeParam
94-
- indexAlloc
95-
- rangeExprCopy
96-
- rangeValCopy
23+
settings:
24+
staticcheck:
25+
checks:
26+
# Below is the default set
27+
- "all"
28+
- "-ST1000"
29+
- "-ST1003"
30+
- "-ST1016"
31+
- "-ST1020"
32+
- "-ST1021"
33+
- "-ST1022"
34+
# FIXME: this below this point is disabled for now, but we should investigate
35+
- "-QF1008" # Omit embedded fields from selector expression https://staticcheck.dev/docs/checks#QF1008
36+
- "-QF1003" # Convert if/else-if chain to tagged switch https://staticcheck.dev/docs/checks#QF1003
37+
- "-QF1009" # Use time.Time.Equal instead of == operator https://staticcheck.dev/docs/checks#QF1009
38+
- "-QF1001" # Apply De Morgan’s law https://staticcheck.dev/docs/checks#QF1001
39+
- "-QF1012" # Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...)) https://staticcheck.dev/docs/checks#QF1012
40+
- "-ST1005" # Expand call to math.Pow https://staticcheck.dev/docs/checks#QF1005
41+
- "-QF1004" # Use strings.ReplaceAll instead of strings.Replace with n == -1 https://staticcheck.dev/docs/checks#QF1004
42+
revive:
43+
enable-all-rules: true
44+
rules:
45+
# See https://revive.run/r
46+
# Below are unsorted, and we might want to review them to decide which one we want to enable
47+
- name: exported
48+
disabled: true
49+
- name: add-constant
50+
disabled: true
51+
- name: cognitive-complexity
52+
disabled: true
53+
- name: package-comments
54+
disabled: true
55+
- name: cyclomatic
56+
disabled: true
57+
- name: deep-exit
58+
disabled: true
59+
- name: function-length
60+
disabled: true
61+
- name: flag-parameter
62+
disabled: true
63+
- name: max-public-structs
64+
disabled: true
65+
- name: max-control-nesting
66+
disabled: true
67+
- name: confusing-results
68+
disabled: true
69+
- name: nested-structs
70+
disabled: true
71+
- name: import-alias-naming
72+
disabled: true
73+
- name: filename-format
74+
disabled: true
75+
- name: use-any
76+
disabled: true
77+
# FIXME: we should enable these below
78+
- name: struct-tag
79+
disabled: true
80+
- name: redundant-import-alias
81+
disabled: true
82+
- name: empty-lines
83+
disabled: true
84+
- name: unhandled-error
85+
disabled: true
86+
- name: confusing-naming
87+
disabled: true
88+
- name: unused-parameter
89+
disabled: true
90+
- name: unused-receiver
91+
disabled: true
92+
- name: import-shadowing
93+
disabled: true
94+
- name: use-errors-new
95+
disabled: true
96+
- name: argument-limit
97+
disabled: true
98+
- name: time-equal
99+
disabled: true
100+
- name: defer
101+
disabled: true
102+
- name: early-return
103+
disabled: true
104+
- name: comment-spacings
105+
disabled: true
106+
- name: function-result-limit
107+
disabled: true
108+
- name: unexported-naming
109+
disabled: true
110+
- name: unnecessary-stmt
111+
disabled: true
112+
- name: if-return
113+
disabled: true
114+
- name: unchecked-type-assertion
115+
disabled: true
116+
- name: bare-return
117+
disabled: true
118+
# Below have been reviewed and disabled
119+
- name: line-length-limit
120+
# Better dealt with by formatter golines
121+
disabled: true
97122

98-
# Style
99-
- assignOp
100-
- boolExprSimplify
101-
- captLocal
102-
- commentFormatting
103-
- commentedOutImport
104-
- defaultCaseOrder
105-
- docStub
106-
- elseif
107-
- emptyFallthrough
108-
- emptyStringTest
109-
- hexLiteral
110-
- ifElseChain
111-
- methodExprCall
112-
- regexpMust
113-
- singleCaseSwitch
114-
- sloppyLen
115-
- stringXbytes
116-
- switchTrue
117-
- typeAssertChain
118-
- typeSwitchVar
119-
- underef
120-
- unlabelStmt
121-
- unlambda
122-
- unslice
123-
- valSwap
124-
- wrapperFunc
125-
- yodaStyleExpr
123+
depguard:
124+
rules:
125+
no-patent:
126+
# do not link in golang-lru anywhere (problematic patent)
127+
deny:
128+
- pkg: github.com/hashicorp/golang-lru/arc/v2
129+
desc: patented (https://github.com/hashicorp/golang-lru/blob/arc/v2.0.7/arc/arc.go#L18)
130+
pkg:
131+
# pkg files must not depend on cobra nor anything in cmd
132+
files:
133+
- '**/pkg/**/*.go'
134+
deny:
135+
- pkg: github.com/spf13/cobra
136+
desc: pkg must not depend on cobra
137+
- pkg: github.com/spf13/pflag
138+
desc: pkg must not depend on pflag
139+
- pkg: github.com/spf13/viper
140+
desc: pkg must not depend on viper
141+
- pkg: github.com/containerd/nerdctl/v2/cmd
142+
desc: pkg must not depend on any cmd files
143+
gocritic:
144+
enabled-checks:
145+
- appendAssign
146+
- argOrder
147+
- badCond
148+
- caseOrder
149+
- codegenComment
150+
- commentedOutCode
151+
- deprecatedComment
152+
- dupArg
153+
- dupBranchBody
154+
- dupCase
155+
- dupSubExpr
156+
- exitAfterDefer
157+
- flagDeref
158+
- flagName
159+
- nilValReturn
160+
- offBy1
161+
- sloppyReassign
162+
- weakCond
163+
- octalLiteral
164+
- appendCombine
165+
- equalFold
166+
- hugeParam
167+
- indexAlloc
168+
- rangeExprCopy
169+
- rangeValCopy
170+
- assignOp
171+
- boolExprSimplify
172+
- captLocal
173+
- commentFormatting
174+
- commentedOutImport
175+
- defaultCaseOrder
176+
- docStub
177+
- elseif
178+
- emptyFallthrough
179+
- emptyStringTest
180+
- hexLiteral
181+
- ifElseChain
182+
- methodExprCall
183+
- regexpMust
184+
- singleCaseSwitch
185+
- sloppyLen
186+
- stringXbytes
187+
- switchTrue
188+
- typeAssertChain
189+
- typeSwitchVar
190+
- underef
191+
- unlabelStmt
192+
- unlambda
193+
- unslice
194+
- valSwap
195+
- wrapperFunc
196+
- yodaStyleExpr
197+
- builtinShadow
198+
- importShadow
199+
- initClause
200+
- nestingReduce
201+
- paramTypeCombine
202+
- ptrToRefParam
203+
- typeUnparen
204+
- unnamedResult
205+
- unnecessaryBlock
206+
exclusions:
207+
generated: disable
126208

127-
# Opinionated
128-
- builtinShadow
129-
- importShadow
130-
- initClause
131-
- nestingReduce
132-
- paramTypeCombine
133-
- ptrToRefParam
134-
- typeUnparen
135-
- unnamedResult
136-
- unnecessaryBlock
137-
138-
depguard:
139-
rules:
140-
# pkg files must not depend on cobra nor anything in cmd
141-
pkg:
142-
files:
143-
- "**/pkg/**/*.go"
144-
deny:
145-
- pkg: "github.com/spf13/cobra"
146-
desc: "pkg must not depend on cobra"
147-
- pkg: "github.com/spf13/pflag"
148-
desc: "pkg must not depend on pflag"
149-
- pkg: "github.com/spf13/viper"
150-
desc: "pkg must not depend on viper"
151-
- pkg: "github.com/containerd/nerdctl/v2/cmd"
152-
desc: "pkg must not depend on any cmd files"
153-
no-patent:
154-
deny:
155-
- pkg: "github.com/hashicorp/golang-lru/arc/v2"
156-
desc: "patented (https://github.com/hashicorp/golang-lru/blob/arc/v2.0.7/arc/arc.go#L18)"
157-
158-
issues:
159-
max-issues-per-linter: 0
160-
max-same-issues: 0
161-
exclude-rules:
162-
- linters:
163-
- revive
164-
text: "unused-parameter"
165-
166-
output:
167-
sort-results: true
209+
formatters:
210+
settings:
211+
gci:
212+
sections:
213+
- standard
214+
- default
215+
- prefix(github.com/containerd)
216+
- localmodule
217+
no-inline-comments: true
218+
no-prefix-comments: true
219+
custom-order: true
220+
gofumpt:
221+
extra-rules: true
222+
golines:
223+
max-len: 100
224+
tab-len: 4
225+
shorten-comments: true
226+
enable:
227+
- gci
228+
- gofmt
229+
# We might consider enabling the following:
230+
# - gofumpt
231+
# - golines
232+
exclusions:
233+
generated: disable

0 commit comments

Comments
 (0)