From 47d2c5ef02995fd2f1c4198094974b17fb353cf8 Mon Sep 17 00:00:00 2001 From: Antoine Gelloz Date: Thu, 18 Apr 2024 11:22:15 +0200 Subject: [PATCH] chore(deps): upgrade to go1.22 --- .golangci.yml | 22 +++++++++++----------- go.mod | 4 ++-- pkg/dag/dag.go | 1 - pkg/dag/node.go | 1 - pkg/dib/build_test.go | 1 - pkg/dib/generate_dag_internal_test.go | 2 -- pkg/dib/list_test.go | 4 ---- pkg/dib/test.go | 1 - pkg/dockerfile/dockerfile_test.go | 1 - pkg/junit/xml_test.go | 2 -- pkg/kaniko/executor_kubernetes_test.go | 1 - pkg/report/report_test.go | 8 -------- pkg/report/template_test.go | 2 -- pkg/report/utils_internal_test.go | 5 ----- pkg/report/utils_test.go | 2 -- pkg/trivy/executor_kubernetes_test.go | 1 - 16 files changed, 13 insertions(+), 45 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ec4e365f..43ee5de5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,16 @@ run: linters: enable-all: true disable: + - maligned # Disable because they are deprecated and throw warning in logs + - interfacer # Disable because they are deprecated and throw warning in logs + - scopelint # Disable because they are deprecated and throw warning in logs + - golint # Disable because they are deprecated and throw warning in logs + - exhaustivestruct # Disable because they are deprecated and throw warning in logs + - ifshort # Disable because they are deprecated and throw warning in logs + - deadcode # Disable because they are deprecated and throw warning in logs + - varcheck # Disable because they are deprecated and throw warning in logs + - structcheck # Disable because they are deprecated and throw warning in logs + - nosnakecase # Disable because they are deprecated and throw warning in logs - cyclop # calculates cyclomatic complexities of functions or packages => legit, but we prefer to use sonarqube and be non-blocking - depguard # We do not have particular restrictions on which packages should be allowed or not - exhaustruct # Find structs that have uninitialized fields. => We want to rely on default field initialization @@ -23,16 +33,6 @@ linters: - wsl # Whitespace Linter - Forces you to use empty lines! => We don't care - wrapcheck # A Go linter to check that errors from external packages are wrapped => A bit too annoying - exhaustive # We don't want to force struct exhaustive - - maligned # Disable because they are deprecated and throw warning in logs - - interfacer # Disable because they are deprecated and throw warning in logs - - scopelint # Disable because they are deprecated and throw warning in logs - - golint # Disable because they are deprecated and throw warning in logs - - exhaustivestruct # Disable because they are deprecated and throw warning in logs - - ifshort # Disable because they are deprecated and throw warning in logs - - dupl # Disable because they are deprecated and throw warning in logs - - deadcode # Disable because they are deprecated and throw warning in logs - - varcheck # Disable because they are deprecated and throw warning in logs - - structcheck # Disable because they are deprecated and throw warning in logs - - nosnakecase # Disable because they are deprecated and throw warning in logs - musttag # Enforce field tags in (un)marshaled structs => Too many false positive errors, and lint code out of project scope - perfsprint # Performance is not an issue + - dupl # Duplicate code necessary in tests diff --git a/go.mod b/go.mod index accdb017..f0ba0db1 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/radiofrance/dib -go 1.21 +go 1.22 -toolchain go1.21.0 +toolchain go1.22.2 require ( github.com/aws/aws-sdk-go-v2 v1.26.1 diff --git a/pkg/dag/dag.go b/pkg/dag/dag.go index 7fe7f2ec..99ea40c7 100644 --- a/pkg/dag/dag.go +++ b/pkg/dag/dag.go @@ -52,7 +52,6 @@ func (d *DAG) WalkAsyncErr(visitor NodeVisitorFuncErr) error { uniqueVisitor := createUniqueVisitorErr(visitor) errG := new(errgroup.Group) for _, node := range d.nodes { - node := node errG.Go(func() error { return node.walkAsyncErr(uniqueVisitor) }) diff --git a/pkg/dag/node.go b/pkg/dag/node.go index eccb0234..99e10458 100644 --- a/pkg/dag/node.go +++ b/pkg/dag/node.go @@ -80,7 +80,6 @@ func (n *Node) walkAsyncErr(visitor NodeVisitorFuncErr) error { return visitor(n) }) for _, childNode := range n.children { - childNode := childNode errG.Go(func() error { return childNode.walkAsyncErr(visitor) }) diff --git a/pkg/dib/build_test.go b/pkg/dib/build_test.go index ac9047d7..e25a2758 100644 --- a/pkg/dib/build_test.go +++ b/pkg/dib/build_test.go @@ -191,7 +191,6 @@ func TestRebuildGraph(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/dib/generate_dag_internal_test.go b/pkg/dib/generate_dag_internal_test.go index b8a61b22..39ce77c2 100644 --- a/pkg/dib/generate_dag_internal_test.go +++ b/pkg/dib/generate_dag_internal_test.go @@ -44,8 +44,6 @@ func Test_loadCustomHumanizedHashList(t *testing.T) { } for _, test := range testCases { - test := test - t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/dib/list_test.go b/pkg/dib/list_test.go index a6c8c4d8..3a82166c 100644 --- a/pkg/dib/list_test.go +++ b/pkg/dib/list_test.go @@ -74,8 +74,6 @@ func Test_GenerateList_GoTemplateFile(t *testing.T) { } for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { t.Parallel() @@ -151,8 +149,6 @@ func Test_ParseOutputOptions(t *testing.T) { } for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/dib/test.go b/pkg/dib/test.go index 62dd78cf..0d5de117 100644 --- a/pkg/dib/test.go +++ b/pkg/dib/test.go @@ -11,7 +11,6 @@ func testImage(testRunners []types.TestRunner, runTestOpts types.RunTestOptions) logger.Infof("Running tests for \"%s\"", runTestOpts.ImageReference) errG := new(errgroup.Group) for _, runner := range testRunners { - runner := runner errG.Go(func() error { if !runner.IsConfigured(runTestOpts) { return nil diff --git a/pkg/dockerfile/dockerfile_test.go b/pkg/dockerfile/dockerfile_test.go index 6431d953..1f2d68bc 100644 --- a/pkg/dockerfile/dockerfile_test.go +++ b/pkg/dockerfile/dockerfile_test.go @@ -167,7 +167,6 @@ func TestParseDockerfile(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/pkg/junit/xml_test.go b/pkg/junit/xml_test.go index f2764ffe..e141149d 100644 --- a/pkg/junit/xml_test.go +++ b/pkg/junit/xml_test.go @@ -97,8 +97,6 @@ func Test_ParseRawLogs(t *testing.T) { } for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/kaniko/executor_kubernetes_test.go b/pkg/kaniko/executor_kubernetes_test.go index 84473827..f5d5c8f5 100644 --- a/pkg/kaniko/executor_kubernetes_test.go +++ b/pkg/kaniko/executor_kubernetes_test.go @@ -75,7 +75,6 @@ func Test_KubernetesExecutor_Execute(t *testing.T) { {"build failed", false}, } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() clientSet := fake.NewSimpleClientset() diff --git a/pkg/report/report_test.go b/pkg/report/report_test.go index ee31f45e..fc631cf3 100644 --- a/pkg/report/report_test.go +++ b/pkg/report/report_test.go @@ -43,7 +43,6 @@ func TestReport_GetRootDir(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() dibReport := report.Report{ @@ -79,7 +78,6 @@ func TestReport_GetBuildLogDir(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() dibReport := report.Report{ @@ -115,8 +113,6 @@ func TestReport_GetJunitReportDir(t *testing.T) { } for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { t.Parallel() dibReport := report.Report{ @@ -152,8 +148,6 @@ func TestReport_GetTrivyReportDir(t *testing.T) { } for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { t.Parallel() dibReport := report.Report{ @@ -236,8 +230,6 @@ func TestReport_CheckError(t *testing.T) { } for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/report/template_test.go b/pkg/report/template_test.go index da66e0dd..0ad36e8a 100644 --- a/pkg/report/template_test.go +++ b/pkg/report/template_test.go @@ -79,7 +79,6 @@ func TestReport_Init(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() @@ -165,7 +164,6 @@ func TestGenerate(t *testing.T) { }, } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/report/utils_internal_test.go b/pkg/report/utils_internal_test.go index 57f8e0b3..3d08406c 100644 --- a/pkg/report/utils_internal_test.go +++ b/pkg/report/utils_internal_test.go @@ -55,7 +55,6 @@ func TestReport_isTestRunnerEnabled(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := isTestRunnerEnabled(test.input.name, test.input.testRunners) @@ -103,7 +102,6 @@ func TestReport_sortBuildReport(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := sortBuildReport(test.input) @@ -184,7 +182,6 @@ func TestReport_sortTrivyScan(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := sortTrivyScan(test.input) @@ -224,7 +221,6 @@ func TestReport_beautifyBuildsLogs(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := beautifyBuildsLogs([]byte(test.input)) @@ -259,7 +255,6 @@ func TestReport_sanitize(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := sanitize(test.input) diff --git a/pkg/report/utils_test.go b/pkg/report/utils_test.go index f1b944af..12be3373 100644 --- a/pkg/report/utils_test.go +++ b/pkg/report/utils_test.go @@ -40,7 +40,6 @@ func TestReport_RemoveTerminalColors(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() actual := report.RemoveTerminalColors([]byte(test.input)) @@ -70,7 +69,6 @@ func TestReport_StripKanikoBuildLogs(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/trivy/executor_kubernetes_test.go b/pkg/trivy/executor_kubernetes_test.go index ba58f032..c28ecd11 100644 --- a/pkg/trivy/executor_kubernetes_test.go +++ b/pkg/trivy/executor_kubernetes_test.go @@ -78,7 +78,6 @@ func Test_KubernetesExecutor_Execute(t *testing.T) { {"build failed", false}, } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() clientSet := fake.NewSimpleClientset()