-
Notifications
You must be signed in to change notification settings - Fork 15
/
.golangci.yml
345 lines (334 loc) · 10.3 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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
run:
timeout: 10m
skip-files: [ ]
skip-dirs:
- pkg/crd/generated/
linters-settings:
govet:
enable-all: true
disable:
- fieldalignment
gocyclo:
min-complexity: 16
maligned:
suggest-new: true
goconst:
min-len: 5
min-occurrences: 3
misspell:
locale: US
funlen:
lines: -1
statements: 50
godox:
keywords:
- FIXME
gofumpt:
extra-rules: true
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/sirupsen/logrus
- github.com/pkg/errors
gocritic:
enabled-tags:
- diagnostic
- style
- performance
disabled-checks:
- sloppyReassign
- rangeValCopy
- octalLiteral
- paramTypeCombine # already handle by gofumpt.extra-rules
- unnamedResult
settings:
hugeParam:
sizeThreshold: 110
gomoddirectives:
replace-allow-list:
- github.com/abbot/go-http-auth
goheader:
values:
const:
COMPANY: Traefik Labs
template: |-
Copyright (C) {{ YEAR-RANGE }} {{ COMPANY }}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
importas:
no-unaliased: true
alias:
# Standard Kubernetes rewrites:
- alias: corev1
pkg: "k8s.io/api/core/v1"
- alias: netv1
pkg: "k8s.io/api/networking/v1"
- alias: netv1beta1
pkg: "k8s.io/api/networking/v1beta1"
- alias: admv1
pkg: "k8s.io/api/admission/v1"
- alias: admv1beta1
pkg: "k8s.io/api/admission/v1beta1"
- alias: extv1beta1
pkg: "k8s.io/api/extensions/v1beta1"
- alias: metav1
pkg: "k8s.io/apimachinery/pkg/apis/meta/v1"
- alias: ktypes
pkg: "k8s.io/apimachinery/pkg/types"
- alias: kerror
pkg: "k8s.io/apimachinery/pkg/api/errors"
- alias: kclientset
pkg: "k8s.io/client-go/kubernetes"
- alias: kinformers
pkg: "k8s.io/client-go/informers"
- alias: ktesting
pkg: "k8s.io/client-go/testing"
- alias: kubefake
pkg: "k8s.io/client-go/kubernetes/fake"
- alias: kschema
pkg: "k8s.io/apimachinery/pkg/runtime/schema"
- alias: kscheme
pkg: "k8s.io/client-go/kubernetes/scheme"
- alias: kversion
pkg: "k8s.io/apimachinery/pkg/version"
- alias: discoveryfake
pkg: "k8s.io/client-go/discovery/fake"
# Kubernetes Gateway rewrites:
- alias: gateclientset
pkg: "sigs.k8s.io/gateway-api/pkg/client/clientset/gateway/versioned"
- alias: gateinformers
pkg: "sigs.k8s.io/gateway-api/pkg/client/informers/gateway/externalversions"
# Traefik Kubernetes rewrites:
- alias: traefikv1alpha1
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/api/traefik/v1alpha1"
- alias: traefikclientset
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/traefik/clientset/versioned"
- alias: traefikinformers
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/traefik/informers/externalversions"
- alias: traefikscheme
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/traefik/clientset/versioned/scheme"
- alias: traefikcrdfake
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/traefik/clientset/versioned/fake"
# Hub Kubernetes rewrites:
- alias: hubv1alpha1
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/api/hub/v1alpha1"
- alias: hubclientset
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/hub/clientset/versioned"
- alias: hubinformers
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/hub/informers/externalversions"
- alias: hublistersv1alpha1
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/hub/listers/hub/v1alpha1"
- alias: hubfake
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/hub/clientset/versioned/fake"
# Misc:
- alias: jwtreq
pkg: "github.com/golang-jwt/jwt/v4/request"
tagalign:
align: false
sort: true
order:
- description
- json
- bson
- toml
- yaml
- yml
- label
- label-slice-as-struct
- file
- kv
- export
revive:
rules:
- name: struct-tag
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
disabled: true
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
disabled: true
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
disabled: true
- name: unreachable-code
- name: redefines-builtin-id
linters:
enable-all: true
disable:
- maligned # deprecated
- interfacer # deprecated
- scopelint # deprecated
- golint # deprecated
- nosnakecase # deprecated
- ifshort # deprecated
- structcheck # deprecated
- exhaustivestruct # deprecated
- deadcode # deprecated
- varcheck # deprecated
- wastedassign # deprecated
- sqlclosecheck # not relevant (SQL)
- rowserrcheck # not relevant (SQL)
- execinquery # not relevant (SQL)
- cyclop # duplicate of gocyclo
- lll
- dupl
- wsl
- nlreturn
- gomnd
- goerr113
- wrapcheck
- exhaustive
- exhaustruct
- nonamedreturns
- testpackage
- tparallel
- paralleltest
- prealloc
- forcetypeassert
- bodyclose # Too many false positives: https://github.com/timakin/bodyclose/issues/30
- ifshort # disable due to false-positive, the linter will be fixed https://github.com/esimonov/ifshort
- varnamelen
- nilnil
- nilerr
- ireturn
- contextcheck
- errchkjson
issues:
exclude-use-default: false
max-per-linter: 0
max-same-issues: 0
exclude:
- 'ST1000: at least one file in a package should have a package comment'
- 'G204: Subprocess launched with variable'
- 'G304: Potential file inclusion via variable'
exclude-rules:
- path: .*_test.go
linters:
- funlen
- noctx
- gochecknoinits
- gochecknoglobals
- maintidx
- path: pkg/crd/api/.*
linters:
- tagliatelle
- path: '(.+)\.go'
text: 'struct-tag: unknown option ''inline'' in JSON tag'
linters:
- revive
- path: pkg/crd/api/.*/v1alpha1/register.go
linters:
- gochecknoglobals
- path: pkg/acp/admission/reviewer/reviewer.go
linters:
- goconst
- path: pkg/metrics/protocol/protocol.go
text: '[[:alpha:]]+V\dSchema is a global variable'
# False positive.
- path: pkg/metrics/store_test.go
text: 'Multiplication of durations: `-1 \* time\.Duration\(n\) \* gran`'
# Keep for historical reason.
- path: pkg/topology/state/cluster.go
text: "json\\(camel\\): got '(metricsURLs)' want '(metricsUrLs)'"
# Reducing cyclomatic complexity would reduce readability.
- path: pkg/acp/admission/reviewer/traefik_ingress_route.go
linters:
- gocyclo
- path: pkg/acp/admission/reviewer/traefik_ingress.go
linters:
- gocyclo
- path: pkg/version/version.go
linters:
- gochecknoglobals
# Harmful to code readability.
- path: pkg/acp/admission/webhook.go
linters:
- errname
- path: pkg/crd/api/hub/v1alpha1/access_control_policy.go
linters:
- gosec # sha1 is not used to encrypt data, no security issue
- path: pkg/acp/watcher.go
linters:
- gocognit
- path: pkg/acp/oidc/oidc.go
text: "Function 'ServeHTTP' has too many statements"
linters:
- funlen
# Reducing cyclomatic complexity would reduce readability.
- path: pkg/acp/oidc/oidc.go
text: "cyclomatic complexity 22 of func `(.*).ServeHTTP` is high"
linters:
- gocyclo
# Reducing cognitive complexity would reduce readability.
- path: pkg/acp/oidc/oidc.go
text: "cognitive complexity 31 of func `(.*).ServeHTTP` is high"
linters:
- gocognit
- path: pkg/acp/oidc/oidc_test.go
text: "G101: Potential hardcoded credentials"
linters:
- gosec
- path: pkg/platform/client_test.go
linters:
- gocognit
# Reducing cyclomatic complexity would reduce readability.
- path: cmd/agent/controller.go
text: "cyclomatic complexity 17 of func `(.*).run` is high"
linters:
- gocyclo
- path: cmd/agent/webhook_admission.go
text: "Function 'setupAdmissionHandlers' has too many statements"
linters:
- funlen
# Reducing cyclomatic complexity would reduce readability.
- path: cmd/agent/auth_server.go
text: "cyclomatic complexity 16 of func `(.*).run` is high"
linters:
- gocyclo
# Intended.
- path: pkg/httpclient/client.go
text: "G402: TLS InsecureSkipVerify may be true"
- path: pkg/acp/config.go
text: "exported fields should be annotated with the \"json\" tag"
linters:
- musttag
- path: portal/embed.go
linters:
- gochecknoglobals
- path: portal/embed.go
text: "pattern dist: no matching files found"
- path: pkg/api/watcher_gateway_test.go
linters:
- gocognit
- path: pkg/api/watcher_gateway_test.go
text: "cyclomatic complexity 18 of func `(.*).run` is high"
linters:
- gocyclo
- path: pkg/api/watcher_portal_test.go
linters:
- gocognit