Skip to content

Commit 8530749

Browse files
committed
preserve comments
Signed-off-by: sivchari <[email protected]>
1 parent a60874e commit 8530749

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

.golangci-kal.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ linters:
3535
- "*" # We will manually enable new linters after understanding the impact. Disable all by default.
3636
lintersConfig:
3737
conditions:
38-
isFirstField: Warn
39-
usePatchStrategy: Forbid
40-
useProtobuf: Forbid
38+
isFirstField: Warn # Require conditions to be the first field in the status struct.
39+
usePatchStrategy: Forbid # Require conditions to be the first field in the status struct.
40+
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
4141
# jsonTags:
4242
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
4343
# optionalOrRequired:

.golangci.yml

+26-2
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,31 @@ linters:
247247
- linters:
248248
- staticcheck
249249
text: 'SA1019: (mhc|m)(.Spec.MaxUnhealthy|.Spec.UnhealthyRange) is deprecated'
250-
# v1Beta1 deprecated fields
250+
# Specific exclude rules for deprecated packages that are still part of the codebase. These
251+
# should be removed as the referenced deprecated packages are removed from the project.
251252
- linters:
252253
- staticcheck
253254
text: 'SA1019: .* is deprecated: This package will be removed in one of the next releases.'
255+
# Specific exclude rules for deprecated types that are still part of the codebase. These
256+
# should be removed as the referenced deprecated types are removed from the project.
254257
- linters:
255258
- staticcheck
256259
text: 'SA1019: (clusterv1alpha3.*|clusterv1alpha4.*) is deprecated: This type will be removed in one of the next releases.'
260+
# Specific exclude rules for deprecated feature flags
257261
- linters:
258262
- staticcheck
259263
text: 'SA1019: feature.ClusterResourceSet is deprecated: ClusterResourceSet feature is now GA and the corresponding feature flag will be removed in 1.12 release.'
264+
# v1Beta1 deprecated fields
260265
- linters:
261266
- staticcheck
262-
text: 'SA1019: .* is deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped.'
267+
text: 'SA1019: .*\.Deprecated\.V1Beta1.* is deprecated'
263268
- linters:
264269
- revive
265270
text: 'exported: exported method .*\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported'
266271
- linters:
267272
- errcheck
268273
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
274+
# Exclude some packages or code to require comments, for example test code, or fake clients.
269275
- linters:
270276
- revive
271277
text: exported (method|function|type|const) (.+) should have comment or be unexported
@@ -282,9 +288,13 @@ linters:
282288
- revive
283289
path: (framework|e2e)/.*.go
284290
text: exported (method|function|type|const) (.+) should have comment or be unexported
291+
# Disable unparam "always receives" which might not be really
292+
# useful when building libraries.
285293
- linters:
286294
- unparam
287295
text: always receives
296+
# Dot imports for gomega and ginkgo are allowed
297+
# within test files and test utils.
288298
- linters:
289299
- revive
290300
- staticcheck
@@ -295,32 +305,44 @@ linters:
295305
- staticcheck
296306
path: (framework|e2e)/.*.go
297307
text: should not use dot imports
308+
# Large parts of this file are duplicate from k/k. Let's ignore "emptyStringTest" to reduce the noise in diffs
309+
# and to avoid making mistakes by diverging from upstream just because of this purely stylistic linter finding.
298310
- linters:
299311
- gocritic
300312
path: internal/topology/variables/clusterclass_variable_validation.go
301313
text: emptyStringTest
314+
# Append should be able to assign to a different var/slice.
302315
- linters:
303316
- gocritic
304317
text: 'appendAssign: append result not assigned to the same slice'
318+
# Disable linters for conversion
305319
- linters:
306320
- staticcheck
307321
path: .*(api|types)\/.*\/conversion.*\.go$
308322
text: 'SA1019: in.(.+) is deprecated'
309323
- linters:
310324
- revive
325+
# Ignoring stylistic checks for generated code
311326
path: .*(api|types|test)\/.*\/conversion.*\.go$
327+
# Checking if an error is nil to just after return the error or nil is redundant
312328
text: 'if-return: redundant if ...; err != nil check, just return error instead'
313329
- linters:
314330
- revive
331+
# Ignoring stylistic checks for generated code
315332
path: .*(api|types|test)\/.*\/conversion.*\.go$
333+
# Exported function and methods should have comments. This warns on undocumented exported functions and methods.
316334
text: exported (method|function|type|const) (.+) should have comment or be unexported
317335
- linters:
318336
- revive
337+
# Ignoring stylistic checks for generated code
319338
path: .*(api|types|test)\/.*\/conversion.*\.go$
339+
# This rule warns when initialism, variable or package naming conventions are not followed.
320340
text: 'var-naming: don''t use underscores in Go names;'
321341
- linters:
322342
- revive
343+
# Ignoring stylistic checks for generated code
323344
path: .*(api|types)\/.*\/conversion.*\.go$
345+
# By convention, receiver names in a method should reflect their identity.
324346
text: 'receiver-naming: receiver name'
325347
- linters:
326348
- staticcheck
@@ -330,10 +352,12 @@ linters:
330352
- staticcheck
331353
path: .*(api|types)\/.*\/conversion.*\.go$
332354
text: 'ST1016: methods on the same type should have the same receiver name'
355+
# We don't care about defer in for loops in test files.
333356
- linters:
334357
- gocritic
335358
path: _test\.go
336359
text: 'deferInLoop: Possible resource leak, ''defer'' is called in the ''for'' loop'
360+
# Ignore non-constant format string in call to condition utils
337361
- linters:
338362
- govet
339363
text: non-constant format string in call to sigs\.k8s\.io\/cluster-api\/util\/conditions\.

scripts/go_install.sh

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ if [ -z "${2}" ]; then
2727
exit 1
2828
fi
2929

30-
echo "${3}"
3130
if [ -z "${3}" ]; then
3231
echo "must provide version as third parameter"
3332
exit 1

0 commit comments

Comments
 (0)