This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.golangci.yml
252 lines (221 loc) · 6 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
run:
# increase timeout for cases when tests run in parallel with linters
timeout: 20m
# which dirs to skip: they won't be analyzed;
skip-dirs:
- pkg
linters-settings:
govet:
# report about shadowed variables
check-shadowing: true
gocyclo:
# minimal code complexity to report
min-complexity: 10
lll:
line-length: 512
linters:
disable-all: true
intentionally-disabled:
# Here is a list of linters we explicitly don't want to enable
# Used for doc and ci purposes. Ignored by golangci-lint
- name: durationcheck
desc: |
durationcheck complains about *any* multiplication of time.Durations, as
*some* might be incorrect. Unfortunately we do need to perform some of
those multiplications.
- name: errname
desc: |
error types should be [xX]xxError. error vars should be errXxx.
nah.
- name: exhaustivestruct [deprecated]
desc: |
exhaustivestruct is meant for special checking only. It verifies that all
fields are set in struct construction, and so is not useful for us
- name: exhaustruct
desc: |
see exhaustivestruct
- name: funlen
desc: |
funlen is annoying
- name: godot
desc: |
godot requires that top-level comments end with a dot. This is useful for
documentation purposes when documentation is generated automatically.
However, we do not document our code and therefore this linter has no
value for us.
- name: goerr113
desc: |
goerr113 requires to not use errors.New, instead it wants us to define
package-level errors and wrap them. This feels to be an overkill so we
are skipping it for now.
- name: gofumpt
desc: |
gofumpt also includes gofumports. These are a stricter version of gofmt
and goimports respectively. By enabling them we also wanted to include
them in our vim configurations to be run on save. Unfortunately this
makes vim.coc report errors very slowly, or not at all. If we decide to
enable them back we should also make sure that they work in our vim
configs.
- name: gomoddirectives
desc: |
gomoddirectives allows only some or outright bans all replace directives
in the go.mod files. Since importing kubernetes packages is a nighmare we
actually need the replace directive.
- name: interfacer [deprecated]
desc: |
interfacer is deprecated
- name: maligned [deprecated]
desc: |
maligned is deprecated
- name: noctx
desc: |
noctx requires using a context when constructing an http.Request.
However, as for the time being we are not passing contexts to our
functions, so just using `context.Background` to make the linter happy
does not really make sense
- name: paralleltest
desc: |
paralleltest seems to think all tests should be parallel. We'll let
ginkgo decide that.
- name: scopelint [deprecated]
desc: |
scopelint is deprecated
- name: tagliatelle
desc: |
complains about our json and yaml tags not being in camel case. Changing
these would be a massive pain
- name: unparam
desc: |
Didn't like it complaining about always using port 8080 in a function
- name: wrapcheck
desc: |
we don't believe in wrapping all errors, especially from our interfaces
- name: golint [deprecated]
desc: |
deprecated as of 1.41.0, replaced by revive
- name: tenv
desc: |
this linter would only make sense if we were using gotest
- name: varnamelen
desc: |
the linter is too agressive
- name: ireturn
desc: |
lots of k8s libraries return interfaces so wrapping them is annoyingly reported by this linter
- name: nolintlint
desc: |
nilerr is disabled while linters catch up with go-1.18, and then nolintlint complains about
where we've ignored nilerr. So turn it off for now. Can be re-enabled when nilerr is no
longer ignored for go-1.18
- name: execinquery
desc: |
we don't use SQL
- name: nonamedreturns
desc: |
we use named returns sometimes
- name: nosprintfhostport
desc: |
we do not construct urls in the production code
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- deadcode
- decorder
- depguard
- dogsled
- dupl
- errcheck
- errchkjson
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godox
- gofmt
- goheader
- goimports
- gomnd
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- lll
- makezero
- maintidx
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- nosnakecase
- prealloc
- predeclared
- promlinter
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unused
- varcheck
- wastedassign
- whitespace
- wsl
issues:
exclude:
- "exported (method|function|type|const|var) (.+) should have comment"
- "comment on exported (method|function|type|const|var) (.+) should be of the form"
exclude-rules:
- path: _test\.go
linters:
- goconst
- dupl
- gomnd
- gochecknoglobals
- gosec
- forcetypeassert
- path: _suite_test\.go
linters:
- gochecknoglobals
- path: tests/.*\.go
linters:
- gomnd
- funlen
- gosec
- golint
- stylecheck
- revive
- path: util/lager_logr.go
linters:
- ireturn
# Maximum issues count per one linter. Set to 0 to disable.
max-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable
max-same: 0
# Show only new issues
new: false