forked from Mirantis/hmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
330 lines (327 loc) · 8.54 KB
/
.golangci.yml
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
run:
timeout: 5m
allow-parallel-runners: true
issues:
# don't skip warning about doc comments
# don't exclude the default set of lint
exclude-use-default: false
# restore some of the defaults
# (fill in the rest as needed)
exclude-rules:
- path: (cmd\/main\.go)|(.*_test\.go)
linters:
- maintidx
- path: test/
linters:
- perfsprint
- errorlint
- exhaustive
- text: 'shadow: declaration of "err" shadows declaration'
linters:
- govet
- text: "fieldalignment: "
path: (.*_test\.go|test\/|api\/?.*\/.*_types\.go) # ignore tests, and k8s API-specific files
linters:
- govet
- text: "max-public-structs: you have exceeded the maximum number of public struct declarations"
linters:
- revive
path: api/ # the api/ pkgs have lots of structs
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- decorder
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- forbidigo
- forcetypeassert
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gocyclo
- gofmt
- gofumpt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- interfacebloat
- intrange
- loggercheck
- maintidx
- misspell
- musttag
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- revive
- staticcheck
- stylecheck
- tenv
- testifylint
- thelper
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
linters-settings:
depguard:
rules:
# Name of a rule.
main:
# Packages that are not allowed where the value is a suggestion.
deny:
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib 'errors' package
- pkg: "github.com/hashicorp/go-multierror"
desc: Should be replaced by standard lib 'errors' package
- pkg: "go.uber.org/multierr"
desc: Should be replaced by standard lib 'errors' package
aliases:
# List of file globs that will match this list of settings to compare against.
# Default: $all
files:
- "!test/**"
- "!**/*_test.go"
deny:
- pkg: "sigs.k8s.io/controller-runtime/pkg/reconcile"
desc: Use aliases from the 'ctrl "sigs.k8s.io/controller-runtime"' package
dupl:
# Tokens count to trigger issue.
# Default: 150
threshold: 200
errcheck:
check-type-assertions: true
check-blank: false
disable-default-exclusions: true
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/Mirantis/hmc) # Custom section: groups all imports with the specified Prefix.
skip-generated: false
gofmt:
# Apply the rewrite rules to the source before reformatting.
# https://pkg.go.dev/cmd/gofmt
# Default: []
rewrite-rules:
- pattern: "interface{}"
replacement: "any"
gofumpt:
extra-rules: true
govet:
disable-all: true
enable:
- appends
- asmdecl
- assign
- atomic
- atomicalign
- bools
- buildtag
- cgocall
- composites
- copylocks
- deepequalerrors
- defers
- directive
- errorsas
- fieldalignment
- findcall
- framepointer
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- nilness
- printf
- reflectvaluecompare
- shadow
- shift
- sigchanyzer
- slog
- sortslice
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
- unusedwrite
loggercheck:
kitlog: false
klog: false
require-string-key: true
no-printf-like: true
paralleltest:
ignore-missing: true
prealloc:
for-loops: true
revive:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
rules:
- name: add-constant
disabled: true
- name: argument-limit
disabled: true
- name: atomic
- name: banned-characters
arguments: ["Ω", "Σ", "σ", "7"]
- name: bare-return
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: cognitive-complexity
disabled: true
- name: comment-spacings
- name: comments-density
disabled: true
- name: confusing-naming
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
arguments:
- allowTypesBefore: "*testing.T"
- name: context-keys-type
- name: cyclomatic
disabled: true
- name: datarace
- name: deep-exit
- name: defer
arguments:
- ["call-chain", "loop", "method-call", "recover", "immediate-recover", "return"]
- name: dot-imports
arguments:
- { allowedPackages: ["github.com/onsi/ginkgo/v2","github.com/onsi/gomega"] }
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: empty-lines
- name: enforce-map-style
arguments: ["make"]
exclude: ["TEST"]
- name: enforce-repeated-arg-type-style
arguments:
- { funcArgStyle = "any", funcRetValStyle = "short" }
- name: enforce-slice-style
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
disabled: true
arguments:
- "checkPrivateReceivers"
- "sayRepetitiveInsteadOfStutters"
- name: file-header
disabled: true
- name: flag-parameter
- name: function-length
disabled: true
- name: function-result-limit
disabled: true
- name: get-return
- name: identical-branches
- name: if-return
- name: import-alias-naming
arguments:
- "^[a-z][a-z0-9]{0,}$"
- name: import-shadowing
- name: imports-blocklist
disabled: true
- name: increment-decrement
- name: indent-error-flow
- name: line-length-limit
disabled: true
- name: max-control-nesting
- name: max-public-structs
exclude: ["TEST"]
arguments: [5]
- name: modifies-parameter
- name: modifies-value-receiver
- name: nested-structs
- name: optimize-operands-order
- name: package-comments
disabled: true
- name: range
- name: range-val-address
- name: range-val-in-closure
- name: receiver-naming
- name: redefines-builtin-id
- name: redundant-import-alias
- name: string-format
arguments:
# TODO: enable commented when existing warnings are fixed
# - - 'fmt.Errorf[0]'
# - '/^([^A-Z]|$)/'
# - 'Error string must not start with a capital letter.'
- - 'fmt.Errorf[0]'
- '/(^|[^\.!?])$/'
- 'Error string must not end in punctuation.'
# - - 'errors.New[0]'
# - '/^([^A-Z]|$)/'
# - 'Error string must not start with a capital letter.'
- - 'errors.New[0]'
- '/(^|[^\.!?])$/'
- 'Error string must not end in punctuation.'
- - 'panic'
- '/^[^\n]*$/'
- 'Must not contain line breaks.'
- name: string-of-int
- name: struct-tag
arguments:
- "json,inline"
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unchecked-type-assertion
- name: unconditional-recursion
- name: unexported-naming
- name: unexported-return
- name: unhandled-error
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
- name: unused-receiver
- name: use-any
- name: useless-break
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
stylecheck:
checks: ["all", "-ST1000", "-ST1001", "-ST1021"]