-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.golangci.yml
More file actions
279 lines (279 loc) · 7.36 KB
/
.golangci.yml
File metadata and controls
279 lines (279 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
version: "2"
run:
concurrency: 8
allow-parallel-runners: true
output:
formats:
text:
path: stdout
linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- decorder
- dogsled
- durationcheck
- errchkjson
- exptostd
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- gocritic
- goheader
- goprintffuncname
- gosmopolitan
- grouper
- iface
- importas
- intrange
- loggercheck
- makezero
- mirror
- nilnesserr
- nosprintfhostport
- reassign
- recvcheck
- revive
- rowserrcheck
- sqlclosecheck
- testableexamples
- testifylint
- unconvert
- usetesting
- wastedassign
- zerologlint
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- cyclop
- dupl
- dupword
- errcheck
- errname
- errorlint
- exhaustive
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- godot
- godox
- gomoddirectives
- gomodguard
- gosec
- inamedparam
- interfacebloat
- ireturn
- lll
- misspell
- mnd
- musttag
- nakedret
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nonamedreturns
- paralleltest
- predeclared
- promlinter
- protogetter
- spancheck
- tagalign
- tagliatelle
- thelper
- tparallel
- unparam
- usestdlibvars
- varnamelen
- whitespace
disable:
- depguard
- err113
- sloglint
- wsl
- exhaustruct
- forbidigo
- testpackage
- wrapcheck
# CLI-specific exclusions - these are too pedantic for command-line tools
- gochecknoglobals # Cobra commands require package-level vars
- gochecknoinits # Cobra flag setup uses init()
- nlreturn # Excessive whitespace requirements
- varnamelen # Short names like 'c' for cobra.Command are idiomatic
- mnd # Magic numbers in CLI flags are fine
- paralleltest # Not all tests benefit from parallelization
- tagliatelle # snake_case in YAML config is conventional
- funlen # Command handlers are naturally longer
- lll # Long lines in help text are acceptable
- godot # Comment punctuation is pedantic
- ireturn # Returning interfaces is fine for formatters
- gomoddirectives # go.mod directives are intentional
- protogetter # Direct proto field access is fine for CLI output
- exhaustive # Not all switch statements need all cases
# Additional pragmatic exclusions for runtime code
- errchkjson # JSON marshal errors in tests are fine
- inamedparam # Named parameters in interfaces are pedantic
- nilnil # Returning nil,nil is acceptable in some cases
- nolintlint # Nolint directives are intentional
- predeclared # Some predeclared names are fine in specific contexts
- whitespace # Trailing whitespace is cosmetic
- unparam # Unused params may be needed for interface compliance
- revive # Often overlaps with other linters
- noctx # Context not always needed for exec.Command
settings:
cyclop:
max-complexity: 20
dupl:
threshold: 250
gocognit:
min-complexity: 120
revive:
rules:
- name: exported
arguments:
- disableStutteringCheck
sloglint:
context: all
staticcheck:
checks:
- all
usetesting:
# The context checks are disabled by default since usetesting v0.5.0, CI is still using an older version,
# so disabling them explicitly for now. These checks have caused some churn for us in CI as well, not all
# occurrences of them are valid.
context-background: false
context-todo: false
exclusions:
generated: lax
rules:
- linters:
- ineffassign
path: conversion\.go
- linters:
- ineffassign
text: ineffectual assignment to ctx
- linters:
- staticcheck
text: this value of `ctx` is never used
- linters:
- wastedassign
text: assigned to ctx, but never used afterwards
- linters:
- forbidigo
path: _test.go$
text: should not be used because managedFields was removed
# Errcheck exclusions for cleanup operations
- linters:
- errcheck
text: "Error return value of.*Close"
- linters:
- errcheck
text: "Error return value of.*Remove"
- linters:
- errcheck
text: "Error return value of.*Wait"
- linters:
- errcheck
text: "Error return value of.*Set"
- linters:
- errcheck
text: "Error return value of.*ReleaseNetworkResources"
- linters:
- errcheck
text: "Error return value of.*io.Copy"
- linters:
- errcheck
path: _test\.go$
- linters:
- gosec
text: G115 # Integer overflow conversion is acceptable for CLI flags
- linters:
- gosec
text: G104 # Unhandled errors covered by errcheck exclusions
- linters:
- gosec
text: G301 # Directory permissions 0755 are standard for system directories
- linters:
- gosec
text: G306 # File permissions 0644 are standard for config files
- linters:
- gosec
text: G204 # Subprocess with variable is intentional (shim launch)
- linters:
- gosec
text: G304 # File inclusion via variable is intentional for CLI
# Service structs legitimately store context for service lifetime
- linters:
- containedctx
path: internal/(guest/vminit/task/service|host/network/network)\.go
# Test style preferences
- linters:
- testifylint
text: "for error assertions use require"
- linters:
- thelper
path: _test\.go$
# Style preferences that are too pedantic
- linters:
- godox
text: "TODO"
- linters:
- nonamedreturns
text: "named return"
- linters:
- inamedparam
text: "parameter name"
- linters:
- unparam
text: "is unused"
# Package comments (can be added incrementally)
- linters:
- staticcheck
text: "ST1000"
# Nil checks are fine
- linters:
- staticcheck
text: "S1009"
# ALL_CAPS for syscall constants is acceptable
- linters:
- staticcheck
text: "ST1003.*ALL_CAPS"
# Type inference suggestions are pedantic
- linters:
- staticcheck
text: "QF1011"
# Force type assert in internal code is acceptable
- linters:
- forcetypeassert
path: internal/
# Errorlint %v in tests is acceptable
- linters:
- errorlint
path: _test\.go$
# Named returns can be useful for readability
- linters:
- nakedret
text: "naked return"
paths:
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$