1
+ run :
2
+ timeout : 10m
3
+ go : " 1.20"
4
+ skip-files :
5
+ - " zz_generated.*\\ .go$"
6
+ - apis/v1alpha3
7
+ allow-parallel-runners : true
8
+
1
9
linters :
2
10
disable-all : true
3
11
enable :
12
+ - asasalint
4
13
- asciicheck
14
+ - bidichk
5
15
- bodyclose
16
+ # - containedctx
6
17
- dogsled
18
+ # - dupword
19
+ - durationcheck
7
20
- errcheck
21
+ # - errchkjson
8
22
- exportloopref
9
23
- gci
24
+ # - ginkgolinter
10
25
- goconst
11
26
- gocritic
12
- - gocyclo
13
27
- godot
14
28
- gofmt
15
29
- goimports
@@ -23,7 +37,8 @@ linters:
23
37
- nakedret
24
38
- nilerr
25
39
- noctx
26
- - nolintlint
40
+ # - nolintlint
41
+ - nosprintfhostport
27
42
- prealloc
28
43
- predeclared
29
44
- revive
@@ -35,42 +50,250 @@ linters:
35
50
- unconvert
36
51
- unparam
37
52
- unused
53
+ - usestdlibvars
38
54
- whitespace
39
55
40
56
linters-settings :
41
57
gci :
42
- local-prefixes : sigs.k8s.io/cluster-api-provider-vsphere
43
- run :
44
- skip-files :
45
- - " .*zz_generated.*\\ .go"
46
- - " contrib/.*"
47
- - " apis/v1alpha3/.*"
48
- - " apis/v1alpha4/.*"
49
- timeout : 5m
50
- issue :
51
- max-same-issues : 0
52
- max-per-linter : 0
58
+ local-prefixes : " sigs.k8s.io/cluster-api-provider-vsphere"
59
+ godot :
60
+ # declarations - for top level declaration comments (default);
61
+ # toplevel - for top level comments;
62
+ # all - for all comments.
63
+ scope : toplevel
64
+ exclude :
65
+ - ' ^ \+.*'
66
+ - ' ^ ANCHOR.*'
67
+ # gocritic:
68
+ # enabled-tags:
69
+ # - diagnostic
70
+ # - experimental
71
+ # - performance
72
+ # disabled-checks:
73
+ # - appendAssign
74
+ # - dupImport # https://github.com/go-critic/go-critic/issues/845
75
+ # - evalOrder
76
+ # - ifElseChain
77
+ # - octalLiteral
78
+ # - regexpSimplify
79
+ # - sloppyReassign
80
+ # - truncateCmp
81
+ # - typeDefFirst
82
+ # - unnamedResult
83
+ # - unnecessaryDefer
84
+ # - whyNoLint
85
+ # - wrapperFunc
86
+ # - rangeValCopy
87
+ # - hugeParam
88
+ # importas:
89
+ # no-unaliased: true
90
+ # alias:
91
+ # # Kubernetes
92
+ # - pkg: k8s.io/api/core/v1
93
+ # alias: corev1
94
+ # - pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
95
+ # alias: apiextensionsv1
96
+ # - pkg: k8s.io/apimachinery/pkg/apis/meta/v1
97
+ # alias: metav1
98
+ # - pkg: k8s.io/apimachinery/pkg/api/errors
99
+ # alias: apierrors
100
+ # - pkg: k8s.io/apimachinery/pkg/util/errors
101
+ # alias: kerrors
102
+ # - pkg: k8s.io/component-base/logs/api/v1
103
+ # alias: logsv1
104
+ # # Controller Runtime
105
+ # - pkg: sigs.k8s.io/controller-runtime
106
+ # alias: ctrl
107
+ # # CAPV
108
+ # - pkg: sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1
109
+ # alias: infrav1
110
+ # - pkg: sigs.k8s.io/cluster-api-provider-vsphere/apis/v1alpha3
111
+ # alias: infrav1alpha3
112
+ # - pkg: sigs.k8s.io/cluster-api-provider-vsphere/apis/v1alpha4
113
+ # alias: infrav1alpha4
114
+ # - pkg: sigs.k8s.io/cluster-api-provider-vsphere/apis/vmware/v1beta1
115
+ # alias: vmwarev1
116
+ # # VMware Operator
117
+ # - pkg: "github.com/vmware-tanzu/vm-operator/api/v1alpha1"
118
+ # alias: vmoprv1
119
+ # # CABPK
120
+ # - pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1
121
+ # alias: bootstrapv1
122
+ # # KCP
123
+ # - pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1
124
+ # alias: controlplanev1
125
+ # # CAPI
126
+ # - pkg: sigs.k8s.io/cluster-api/api/v1alpha3
127
+ # alias: clusterv1alpha3
128
+ # - pkg: sigs.k8s.io/cluster-api/api/v1alpha4
129
+ # alias: clusterv1alpha4
130
+ # - pkg: sigs.k8s.io/cluster-api/api/v1beta1
131
+ # alias: clusterv1
132
+ # # CAPI exp
133
+ # - pkg: sigs.k8s.io/cluster-api/exp/api/v1beta1
134
+ # alias: expv1
135
+ # # CAPI exp addons
136
+ # - pkg: sigs.k8s.io/cluster-api/exp/addons/api/v1beta1
137
+ # alias: addonsv1
138
+ nolintlint :
139
+ allow-unused : false
140
+ allow-leading-space : false
141
+ require-specific : true
142
+ revive :
143
+ rules :
144
+ # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
145
+ - name : blank-imports
146
+ - name : context-as-argument
147
+ - name : context-keys-type
148
+ - name : dot-imports
149
+ - name : error-return
150
+ - name : error-strings
151
+ - name : error-naming
152
+ - name : exported
153
+ - name : if-return
154
+ - name : increment-decrement
155
+ - name : var-naming
156
+ - name : var-declaration
157
+ - name : package-comments
158
+ - name : range
159
+ - name : receiver-naming
160
+ - name : time-naming
161
+ - name : unexported-return
162
+ - name : indent-error-flow
163
+ - name : errorf
164
+ - name : empty-block
165
+ - name : superfluous-else
166
+ - name : unused-parameter
167
+ - name : unreachable-code
168
+ - name : redefines-builtin-id
169
+ #
170
+ # Rules in addition to the recommended configuration above.
171
+ #
172
+ - name : bool-literal-in-expr
173
+ - name : constant-logical-expr
174
+
53
175
issues :
176
+ max-same-issues : 0
177
+ max-issues-per-linter : 0
178
+ # We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant
179
+ # changes in PRs and avoid nitpicking.
180
+ exclude-use-default : false
54
181
exclude-rules :
55
- # Specific exclude rules for deprecated fields that are still part of the codebase. These
56
- # should be removed as the referenced deprecated item is removed from the project.
57
- - linters :
58
- - staticcheck
59
- text : " SA1019: failureDomain.AutoConfigure is deprecated"
60
- # Specific exclude rules for deprecated packages that are still part of the codebase. These
61
- # should be removed as the referenced deprecated packages are removed from the project.
62
- - linters :
63
- - staticcheck
64
- text : " SA1019: .* is deprecated: This package will be removed in one of the next releases."
65
- - path : " test/e2e/*"
66
- linters :
67
- - gosec
68
- text : " G106:"
69
- - linters :
70
- - revive
71
- text : " dot-imports"
72
- path : " .*test.*"
73
- - linters :
74
- - stylecheck
75
- text : " ST1001"
76
- path : " .*test.*"
182
+ # Specific exclude rules for deprecated fields that are still part of the codebase. These
183
+ # should be removed as the referenced deprecated item is removed from the project.
184
+ # Specific exclude rules for deprecated packages that are still part of the codebase. These
185
+ # should be removed as the referenced deprecated packages are removed from the project.
186
+ - linters :
187
+ - staticcheck
188
+ text : " SA1019: .* is deprecated: This package will be removed in one of the next releases."
189
+ - linters :
190
+ - revive
191
+ text : " exported: exported method .*\\ .(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported"
192
+ - linters :
193
+ - errcheck
194
+ text : Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
195
+ # Exclude some packages or code to require comments, for example test code, or fake clients.
196
+ - linters :
197
+ - revive
198
+ text : exported (method|function|type|const) (.+) should have comment or be unexported
199
+ source : (func|type).*Fake.*
200
+ - linters :
201
+ - revive
202
+ text : exported (.+) (.+) should have comment (.*)or be unexported
203
+ path : " ^(test/|packaging/|pkg/.*/fake/|pkg/util/testutil).*.go"
204
+ # Disable unparam "always receives" which might not be really
205
+ # useful when building libraries.
206
+ - linters :
207
+ - unparam
208
+ text : always receives
209
+ # Dot imports for gomega and ginkgo are allowed
210
+ # within test files and test utils.
211
+ - linters :
212
+ - revive
213
+ - stylecheck
214
+ path : test/.*.go
215
+ text : should not use dot imports
216
+ # Append should be able to assign to a different var/slice.
217
+ - linters :
218
+ - gocritic
219
+ text : " appendAssign: append result not assigned to the same slice"
220
+ # Disable linters for conversion
221
+ - linters :
222
+ - staticcheck
223
+ text : " SA1019: in.(.+) is deprecated"
224
+ path : ^apis\/.*\/.*conversion.*\.go$
225
+ - linters :
226
+ - revive
227
+ # Checking if an error is nil to just after return the error or nil is redundant
228
+ text : " if-return: redundant if ...; err != nil check, just return error instead"
229
+ # Ignoring stylistic checks for generated code
230
+ path : ^apis\/.*\/.*conversion.*\.go$
231
+ - linters :
232
+ - revive
233
+ # Exported function and methods should have comments. This warns on undocumented exported functions and methods.
234
+ text : exported (method|function|type|const) (.+) should have comment or be unexported
235
+ # Ignoring stylistic checks for generated code
236
+ path : ^apis\/.*\/.*conversion.*\.go$
237
+ - linters :
238
+ - revive
239
+ # This rule warns when initialism, variable or package naming conventions are not followed.
240
+ text : " var-naming: don't use underscores in Go names;"
241
+ # Ignoring stylistic checks for generated code
242
+ path : ^apis\/.*\/.*conversion.*\.go$
243
+ - linters :
244
+ - revive
245
+ # By convention, receiver names in a method should reflect their identity.
246
+ text : " receiver-naming: receiver name"
247
+ # Ignoring stylistic checks for generated code
248
+ path : ^apis\/.*\/.*conversion.*\.go$
249
+ - linters :
250
+ - stylecheck
251
+ text : " ST1003: should not use underscores in Go names;"
252
+ path : ^apis\/.*\/.*conversion.*\.go$
253
+ - linters :
254
+ - stylecheck
255
+ text : " ST1016: methods on the same type should have the same receiver name"
256
+ path : ^apis\/.*\/.*conversion.*\.go$
257
+
258
+ # FIXME: All below excludes should get removed over time.
259
+ - linters :
260
+ - staticcheck
261
+ text : " SA1019: failureDomain.AutoConfigure is deprecated"
262
+ - path : " test/e2e/*"
263
+ linters :
264
+ - gosec
265
+ text : " G106:"
266
+
267
+ # missing comments
268
+ - linters :
269
+ - revive
270
+ text : " package-comments"
271
+ path : ^(main|(packaging|apis|controllers|feature|test|pkg)\/.*)\.go$
272
+ - linters :
273
+ - stylecheck
274
+ text : " ST1000"
275
+ path : ^(main|(packaging|apis|controllers|feature|test|pkg)\/.*)\.go$
276
+ - linters :
277
+ - revive
278
+ text : exported (.*) should have comment (.*)or be unexported
279
+ path : " ^(apis|controllers|packaging|pkg)/.*.go"
280
+
281
+ # wrong comment
282
+ - linters :
283
+ - revive
284
+ text : comment on exported (.*) should be of the form (.*)
285
+ path : " ^(apis|packaging|pkg/(constants|services|util))/"
286
+ - linters :
287
+ - stylecheck
288
+ text : ST1021|ST1020
289
+ path : " ^(apis|packaging|pkg/(constants|services|util))/"
290
+
291
+ # gosec
292
+ - linters :
293
+ - gosec
294
+ text : " G104: Errors unhandled."
295
+ path : ^(controllers/vspherecluster_reconciler|pkg/manager/options_test|test/helpers/webhook)\.go$
296
+ - linters :
297
+ - gosec
298
+ text : " (G204|G301|G304): "
299
+ path : ^test/
0 commit comments