forked from mmatur/hub-agent-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
271 lines (261 loc) · 8.35 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
run:
deadline: 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: clientset
pkg: "k8s.io/client-go/kubernetes"
- alias: kubemock
pkg: "k8s.io/client-go/kubernetes/fake"
# 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: traefikinformer
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/traefik/informers/externalversions"
- alias: traefikkubemock
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: hubinformer
pkg: "github.com/traefik/hub-agent-kubernetes/pkg/crd/generated/client/hub/informers/externalversions"
- alias: hubkubemock
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"
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
- musttag
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'
- 'package-comments: should have a package comment'
exclude-rules:
- path: .*_test.go
linters:
- funlen
- noctx
- gochecknoinits
- gochecknoglobals
- maintidx
- path: pkg/crd/api/.*
linters:
- tagliatelle
- 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
# 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
# Reducing complexity would reduce readability.
- path: pkg/acp/apikey/api_key.go
text: "(.*) has complex nested blocks \\(complexity: 5\\)"