From a174bd46cae5a4ce7d15fa17f94193861de3656d Mon Sep 17 00:00:00 2001 From: Alan Parra Date: Wed, 8 Jan 2025 12:54:21 -0300 Subject: [PATCH] [v15] chore: Bump golangci-lint to v1.63.4 (#50868) * chore: Bump golangci-lint to v1.63.4 (#50846) * chore: Bump golangci-lint to v1.63.4 * Change output.uniq-by-line to issues.uniq-by-line * fix: Use require.NoError when appropriate * Ignore govet warnings related to Go 1.22 * fix: Address loopvar issues in various tests * Update e/ --- .golangci.yml | 12 +++++++++--- build.assets/versions.mk | 2 +- e | 2 +- lib/devicetrust/assert/assert_test.go | 1 + lib/events/export/date_exporter_test.go | 2 ++ lib/events/export/exporter_test.go | 1 + lib/integrations/awsoidc/eks_enroll_clusters_test.go | 6 +++--- lib/services/local/access_list_test.go | 2 +- lib/services/role_test.go | 2 +- tool/tsh/common/tsh_test.go | 1 + 10 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 774063281342d..70151566c5c45 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,10 +24,19 @@ issues: - linters: [testifylint] text: "suite-thelper: suite helper method must start with" path: 'integrations/.+' + # Go 1.22 related warnings. + # These are OK because our toolchain is 1.22 or newer. + - linters: [govet] + text: "stdversion: cmp.Or requires go1.22 or later" + - linters: [govet] + text: "stdversion: rand.New requires go1.22 or later" + - linters: [govet] + text: "stdversion: rand.NewPCG requires go1.22 or later" exclude-use-default: true max-same-issues: 0 max-issues-per-linter: 0 + uniq-by-line: false linters: disable-all: true @@ -147,9 +156,6 @@ linters-settings: - suite-extra-assert-call - suite-thelper -output: - uniq-by-line: false - run: go: '1.21' build-tags: [] diff --git a/build.assets/versions.mk b/build.assets/versions.mk index 365696c236b89..78618c590455b 100644 --- a/build.assets/versions.mk +++ b/build.assets/versions.mk @@ -4,7 +4,7 @@ # Sync with devbox.json. GOLANG_VERSION ?= go1.22.10 -GOLANGCI_LINT_VERSION ?= v1.61.0 +GOLANGCI_LINT_VERSION ?= v1.63.4 NODE_VERSION ?= 20.18.0 diff --git a/e b/e index f48078310ec68..4d9ada8bcffbb 160000 --- a/e +++ b/e @@ -1 +1 @@ -Subproject commit f48078310ec68405d30135ba2d27a0160ef42c42 +Subproject commit 4d9ada8bcffbbe5d9f0fb31e58040eab7dc723c0 diff --git a/lib/devicetrust/assert/assert_test.go b/lib/devicetrust/assert/assert_test.go index b9068b222df2e..6d4021a526e77 100644 --- a/lib/devicetrust/assert/assert_test.go +++ b/lib/devicetrust/assert/assert_test.go @@ -57,6 +57,7 @@ func TestCeremony(t *testing.T) { }, } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/lib/events/export/date_exporter_test.go b/lib/events/export/date_exporter_test.go index a6907ade60015..4aeda4df4c19a 100644 --- a/lib/events/export/date_exporter_test.go +++ b/lib/events/export/date_exporter_test.go @@ -42,6 +42,7 @@ import ( func TestDateExporterBasics(t *testing.T) { t.Parallel() for _, randomFlake := range []bool{false, true} { + randomFlake := randomFlake t.Run(fmt.Sprintf("randomFlake=%v", randomFlake), func(t *testing.T) { t.Parallel() testDateExporterBasics(t, randomFlake) @@ -197,6 +198,7 @@ func testDateExporterBasics(t *testing.T, randomFlake bool) { func TestDateExporterResume(t *testing.T) { t.Parallel() for _, randomFlake := range []bool{false, true} { + randomFlake := randomFlake t.Run(fmt.Sprintf("randomFlake=%v", randomFlake), func(t *testing.T) { t.Parallel() testDateExporterResume(t, randomFlake) diff --git a/lib/events/export/exporter_test.go b/lib/events/export/exporter_test.go index 436cd3ecccf52..79e665c24bb99 100644 --- a/lib/events/export/exporter_test.go +++ b/lib/events/export/exporter_test.go @@ -41,6 +41,7 @@ func TestExporterBasics(t *testing.T) { startDate := now.Add(-7 * day) for _, randomFlake := range []bool{false, true} { + randomFlake := randomFlake // empty case verified export of a time range larger than backlog size with no events in it. t.Run(fmt.Sprintf("case=empty,randomFlake=%v", randomFlake), func(t *testing.T) { diff --git a/lib/integrations/awsoidc/eks_enroll_clusters_test.go b/lib/integrations/awsoidc/eks_enroll_clusters_test.go index 6c1cb6996239a..a4f3d70b4cd2f 100644 --- a/lib/integrations/awsoidc/eks_enroll_clusters_test.go +++ b/lib/integrations/awsoidc/eks_enroll_clusters_test.go @@ -170,7 +170,7 @@ func TestEnrollEKSClusters(t *testing.T) { responseCheck: func(t *testing.T, response *EnrollEKSClusterResponse) { require.Len(t, response.Results, 1) require.Equal(t, "EKS1", response.Results[0].ClusterName) - require.Empty(t, response.Results[0].Error) + require.NoError(t, response.Results[0].Error) require.NotEmpty(t, response.Results[0].ResourceId) }, }, @@ -186,10 +186,10 @@ func TestEnrollEKSClusters(t *testing.T) { return strings.Compare(a.ClusterName, b.ClusterName) }) require.Equal(t, "EKS1", response.Results[0].ClusterName) - require.Empty(t, response.Results[0].Error) + require.NoError(t, response.Results[0].Error) require.NotEmpty(t, response.Results[0].ResourceId) require.Equal(t, "EKS2", response.Results[1].ClusterName) - require.Empty(t, response.Results[1].Error) + require.NoError(t, response.Results[1].Error) require.NotEmpty(t, response.Results[1].ResourceId) }, }, diff --git a/lib/services/local/access_list_test.go b/lib/services/local/access_list_test.go index 9e277adfa5f8a..bd8f237e7309d 100644 --- a/lib/services/local/access_list_test.go +++ b/lib/services/local/access_list_test.go @@ -801,7 +801,7 @@ func TestAccessListReviewCRUD(t *testing.T) { // Verify that access lists reviews are gone. _, _, err = service.ListAccessListReviews(ctx, accessList1.GetName(), 0, "") - require.Empty(t, err) + require.NoError(t, err) } func TestAccessListRequiresEqual(t *testing.T) { diff --git a/lib/services/role_test.go b/lib/services/role_test.go index 10849d4689838..a571d46916319 100644 --- a/lib/services/role_test.go +++ b/lib/services/role_test.go @@ -1040,7 +1040,7 @@ func TestValidateRole(t *testing.T) { require.NoError(t, err, trace.DebugReport(err)) if len(tc.expectWarnings) == 0 { - require.Empty(t, warning) + require.NoError(t, warning) } for _, msg := range tc.expectWarnings { require.ErrorContains(t, warning, msg) diff --git a/tool/tsh/common/tsh_test.go b/tool/tsh/common/tsh_test.go index b3892c18acd93..62035cd485f9d 100644 --- a/tool/tsh/common/tsh_test.go +++ b/tool/tsh/common/tsh_test.go @@ -6319,6 +6319,7 @@ func TestInteractiveCompatibilityFlags(t *testing.T) { require.NoError(t, err) for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() err := exec.Command(tshBin, "ssh", tt.flag, hostname, tty).Run()