Skip to content

Commit b12e065

Browse files
committed
Bump golangci-lint to v2.12.2 and quiet new findings
1 parent 86c7699 commit b12e065

9 files changed

Lines changed: 47 additions & 9 deletions

File tree

.custom-gcl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: v2.7.0
1+
version: v2.12.2
22
name: golangci-lint-kube-api-linter
33
destination: ./hack/tools/bin
44
plugins:

.github/workflows/pr-golangci-lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
if: matrix.working-directory == ''
3535
run: |
3636
make golangci-lint
37-
hack/tools/bin/golangci-lint-v2.7.0 custom
37+
hack/tools/bin/golangci-lint-v2.12.2 custom
3838
3939
- name: golangci-lint (root with kube-api-linter)
4040
if: matrix.working-directory == ''
@@ -45,5 +45,5 @@ jobs:
4545
uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # tag=v9.2.1
4646
with:
4747
# update the version when updating golangci-lint
48-
version: v2.7.0
48+
version: v2.12.2
4949
working-directory: ${{matrix.working-directory}}

.golangci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ linters:
5151
- usetesting # reports uses of functions with replacement inside the testing package
5252
- whitespace # unnecessary newlines
5353
settings:
54+
goconst:
55+
# goconst now counts occurrences package-wide. Ignore common strings that
56+
# are intentionally not constants to avoid noise from this newer behavior.
57+
ignore-string-values: '^(1\.0|true|1\.28\.12|cncf-upstream|containerd|Cluster|vmss|azure\.json|AzureManagedMachinePool|MachinePool|test-cluster|custom-vnet|my-vnet|spec|name)$'
5458
exhaustruct:
5559
include:
5660
# Hub ASO agent pools should be fully defined to prevent unnecessary updates
@@ -260,6 +264,30 @@ linters:
260264
- linters:
261265
- staticcheck
262266
text: 'QF1008: could remove embedded field'
267+
- linters:
268+
- staticcheck
269+
text: 'QF1012:'
270+
# The govet "inline" analyzer only emits informational notes; ignore them.
271+
- linters:
272+
- govet
273+
text: 'cannot inline'
274+
# gosec credential/taint rules: false positives in test fixtures.
275+
- linters:
276+
- gosec
277+
path: _test\.go
278+
text: '(G101|G705):'
279+
- linters:
280+
- gosec
281+
path: ^test/
282+
text: 'G703:'
283+
- linters:
284+
- gosec
285+
path: ^test/e2e/
286+
text: 'G204:'
287+
# images.go is a version-to-image data map; goconst noise on map values.
288+
- linters:
289+
- goconst
290+
path: azure/services/virtualmachineimages/images\.go$
263291
# We don't care about defer in for loops in test files.
264292
- linters:
265293
- gocritic

azure/scope/identity_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ func TestGetTokenCredential(t *testing.T) {
440440
},
441441
cacheExpect: func(cache *mock_azure.MockCredentialCache) {
442442
ctx := context.Background()
443-
credsPath := "../../test/setup/credentials.json" //nolint:gosec
443+
credsPath := "../../test/setup/credentials.json"
444444
clientOptions := azcore.ClientOptions{
445445
Cloud: cloud.Configuration{
446446
ActiveDirectoryAuthorityHost: "https://login.microsoftonline.com/",

controllers/helpers_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ const (
532532
"useInstanceMetadata": true,
533533
"enableVmssFlexNodes": true
534534
}`
535-
//nolint:gosec // Ignore "G101: Potential hardcoded credentials" check.
536535
spWorkerNodeCloudConfig = `{
537536
"cloud": "AzurePublicCloud",
538537
"tenantId": "fooTenant",

internal/webhooks/azuremachine_validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ func validateAzureMachineSpec(spec infrav1.AzureMachineSpec) field.ErrorList {
8383

8484
// ValidateNetwork validates the network configuration.
8585
func ValidateNetwork(subnetName string, acceleratedNetworking *bool, networkInterfaces []infrav1.NetworkInterface, fldPath *field.Path) field.ErrorList {
86-
if (networkInterfaces != nil) && len(networkInterfaces) > 0 && subnetName != "" {
86+
if len(networkInterfaces) > 0 && subnetName != "" {
8787
return field.ErrorList{field.Invalid(fldPath, networkInterfaces, "cannot set both networkInterfaces and machine subnetName")}
8888
}
8989

90-
if (networkInterfaces != nil) && len(networkInterfaces) > 0 && acceleratedNetworking != nil {
90+
if len(networkInterfaces) > 0 && acceleratedNetworking != nil {
9191
return field.ErrorList{field.Invalid(fldPath, networkInterfaces, "cannot set both networkInterfaces and machine acceleratedNetworking")}
9292
}
9393

pkg/ot/traces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func RegisterTracing(ctx context.Context, log logr.Logger) error {
4242
otel.SetTracerProvider(tp)
4343

4444
// Give the tracer provider 5 seconds to shut down when the context closes.
45-
go func() {
45+
go func() { //nolint:gosec // G118: a fresh context is created below because the request context is already cancelled here.
4646
<-ctx.Done()
4747
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
4848
defer cancel()

test/.golangci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ linters:
261261
- linters:
262262
- staticcheck
263263
text: 'QF1008: could remove embedded field'
264+
- linters:
265+
- staticcheck
266+
text: 'QF1012:'
267+
# The govet "inline" analyzer only emits informational notes; ignore them.
268+
- linters:
269+
- govet
270+
text: 'cannot inline'
271+
# gosec taint rules: false positives in test code.
272+
- linters:
273+
- gosec
274+
text: '(G204|G703):'
264275
paths:
265276
- zz_generated\.(\w*)\.go$
266277
- third_party$

test/e2e/azure_kuberay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func InstallHelmChart(ctx context.Context, clusterProxy framework.ClusterProxy,
262262
"--timeout", "5m0s",
263263
}
264264
helmArgs = append(helmArgs, extraArgs...)
265-
installCmd := exec.CommandContext(ctx, "helm", helmArgs...) //nolint:gosec
265+
installCmd := exec.CommandContext(ctx, "helm", helmArgs...)
266266
installCmd.Env = append(installCmd.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubeconfigPath))
267267
output, err = installCmd.CombinedOutput()
268268
Logf("helm install output: %s", string(output))

0 commit comments

Comments
 (0)