-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path.golangci.yml
More file actions
264 lines (260 loc) · 8 KB
/
.golangci.yml
File metadata and controls
264 lines (260 loc) · 8 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
---
version: "2"
linters:
default: none
settings:
depguard:
rules:
main:
deny:
- pkg: github.com/mcuadros/go-version
desc: Use coreos/go-semver instead
embeddedstructfieldcheck:
# Checks that there is an empty space between the embedded fields and regular fields.
empty-line: false
errcheck:
exclude-functions:
- encoding/json.Marshal
- encoding/json.MarshalIndent
errchkjson:
check-error-free-encoding: true
report-no-exported: true
gocritic:
disabled-checks:
- ifElseChain
- unnamedResult
enabled-tags:
- diagnostic
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
godot:
exclude:
- ^\s*\+
goheader:
template: |-
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the Submariner project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
govet:
enable:
- fieldalignment
lll:
line-length: 140
revive:
rules:
- name: dot-imports
arguments:
- allowed-packages: ["github.com/onsi/ginkgo/v2", "github.com/onsi/gomega"]
staticcheck:
dot-import-whitelist:
- github.com/onsi/ginkgo/v2
- github.com/onsi/gomega
checks:
# Defaults
- all
- -ST1000
- -ST1003
- -ST1016
- -ST1020
- -ST1021
- -ST1022
# Allow if/else constructs that could be switches
- -QF1003
# Allow unnecessary embedded field selectors
- -QF1008
wrapcheck:
extra-ignore-sigs:
- .Error(
wsl_v5:
disable:
- decl
- expr
- send
enable:
# - arangolint # We don't use arangodb
- asasalint
- asciicheck
- bidichk
- bodyclose
# - canonicalheader # This is a slow linter and we don't use the net/http.Header API
- containedctx
- contextcheck
- copyloopvar
# - cyclop # This is equivalent to gocyclo
- decorder
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- embeddedstructfieldcheck
- err113
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
# - exhaustruct # This is too cumbersome as it requires all string, int, pointer et al fields to be initialized even when the
# type's default suffices, which is most of the time
- exptostd
- fatcontext
# - forbidigo # We don't forbid any statements
# - forcetypeassert # There are many unchecked type assertions that would be the result of a programming error so the
# reasonable recourse would be to panic anyway if checked so this doesn't seem useful
# - funcorder # TODO Evaluate whether this is worth it
# - funlen # gocyclo is enabled which is generally a better metric than simply LOC.
- ginkgolinter
- gocheckcompilerdirectives
# - gochecknoglobals # We don't want to forbid global variable constants
# - gochecknoinits # We use init functions for valid reasons
# - gochecksumtype # The usefulness is very narrow
- gocognit
- goconst
- gocritic
- gocyclo
- godoclint
- godot
# - godox # Let's not forbid inline TODOs, FIXMEs et al
- goheader
# - gomoddirectives # We don't want to forbid the 'replace' directive
# - gomodguard # We don't block any modules
# - goprintffuncname # This doesn't seem useful at all
- gosec
# - gosmopolitan # This is related to internationalization which is not a concern for us
- govet
- grouper
- iface
- importas
- inamedparam
- ineffassign
# - interfacebloat # We track complexity elsewhere
- intrange
- iotamixing
# - ireturn # The argument to always "Return Concrete Types" doesn't seem compelling. It is perfectly valid to return
# an interface to avoid exposing the entire underlying struct
- lll
- loggercheck
- maintidx
- makezero
- mirror
- misspell
# - mnd # It doesn't seem useful in general to enforce constants for all numeric values
- modernize
# - musttag # TODO Our JSON structs should be tagged
- nakedret
# - nestif # This calculates cognitive complexity but we're doing that elsewhere
- nilerr
- nilnesserr
- nilnil
# - nlreturn # This is reasonable with a block-size of 2 but setting it above isn't honored
# - noctx # We don't send HTTP requests
- nolintlint
- nonamedreturns
# - nosprintfhostport # The use of this is very narrow
# - paralleltest # Not relevant for Ginkgo UTs
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- recvcheck
- revive
# - rowserrcheck # We don't use SQL
# - sloglint # We don't use log/slog
# - spancheck # We don't use OpenTelemetry/OpenCensus
# - sqlclosecheck # We don't use SQL
- staticcheck
- tagalign
# - tagliatelle # Inconsistent with stylecheck and not as good
# - testableexamples # We don't need this
# - testifylint # We don't use testify
- testpackage
# - thelper # Not relevant for our Ginkgo UTs
# - tparallel # Not relevant for our Ginkgo UTs
- unconvert
- unparam
# - unqueryvet # We don't use SQL
- unused
- usestdlibvars
- usetesting
# - varnamelen # It doesn't seem necessary to enforce a minimum variable name length
- wastedassign
- whitespace
- wrapcheck
- wsl_v5
# - zerologlint # We use zerolog indirectly so this isn't needed
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# Ignore long line and variable name non-compliance warnings in auto-generated file
- linters:
- lll
- revive
- staticcheck
path: pkg/embeddedyamls/yamls.go
# BrokerK8sApiServer parameter is used by other projects, like ACM,
# so not changing it to BrokerK8sAPIServer as suggested by stylecheck
- linters:
- revive
- staticcheck
text: struct field BrokerK8sApiServer
# Ignore pointer bytes in struct alignment tests (this is a very
# minor optimisation)
- linters:
- govet
text: pointer bytes could be
# Full text of the error is "do not define dynamic errors, use wrapped static errors instead". See
# https://github.com/Djarvur/go-err113/issues/10 for an interesting discussion of this error. While there are cases
# where wrapped sentinel errors are useful, it seems a bit pedantic to force that pattern in all cases.
- linters:
- err113
text: do not define dynamic errors
# Ignore certain linters for test files
- linters:
- err113
- errname
- gochecknoinits
- wrapcheck
path: _test\.go|test/|fake/
# Ignore header linting for internal files copied from Kubernetes
- linters:
- goheader
path: internal/(cli|env|log)/.*\.go
# Ignore header linting for build constraint
# See https://github.com/denis-tingaikin/go-header/issues/18
- linters:
- goheader
path: cmd/subctl/.*\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$