From 32ca82b857e6b3174a046c1bd779b880efb91e21 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Fri, 20 Dec 2024 08:07:53 +0100 Subject: [PATCH] chore: upgrade Golang to 1.23 and Linter (#1445) --- .github/workflows/PR.yaml | 4 ++++ .github/workflows/lint.yaml | 4 ++-- .golangci.yml | 15 +++++++-------- auth/tokenizer.go | 2 +- go.mod | 4 ++-- scripts/local-dev/go.mod | 4 ++-- service/cluster/cluster.go | 2 -- service/flavor.go | 1 - 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/PR.yaml b/.github/workflows/PR.yaml index 1521d9c3e..1a2d84d11 100644 --- a/.github/workflows/PR.yaml +++ b/.github/workflows/PR.yaml @@ -75,6 +75,10 @@ jobs: USE_GKE_GCLOUD_AUTH_PLUGIN: "True" steps: + - uses: actions/setup-go@v5 + with: + go-version: "1.23" + - name: Checkout uses: actions/checkout@v4 with: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index bea0a8308..fc65a7676 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.23" - name: Checkout uses: actions/checkout@v4 with: @@ -26,7 +26,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.58 + version: v1.62 shellcheck: runs-on: ubuntu-latest diff --git a/.golangci.yml b/.golangci.yml index 88933334b..1576d6740 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,8 +1,12 @@ run: timeout: 16m + go: "1.23" output: - format: "junit-xml:report.xml,colored-line-number" + formats: + - format: colored-line-number + - format: junit-xml + path: report.xml issues: exclude-use-default: false @@ -36,7 +40,7 @@ linters-settings: includes: - G601 revive: - min-confidence: 0 + confidence: 0 govet: enable-all: true disable: @@ -56,16 +60,11 @@ linters-settings: - Warnf - Error - Errorf - gocritic: - enabled-checks: - - commentFormatting nolintlint: - allow-leading-space: false # require machine-readable nolint directives (i.e. with no leading space) allow-unused: false # report any unused nolint directives require-explanation: false # don't require an explanation for nolint directives require-specific: true # require nolint directives to be specific about which linter is being skipped staticcheck: - go: "1.20" checks: [all, -ST1000, -ST1001, -ST1003, -ST1005, -SA1019, -SA4001, -ST1016] wrapcheck: ignoreSigRegexps: @@ -81,6 +80,7 @@ linters: enable: - asciicheck # - bodyclose + - copyloopvar # - deadcode # - depguard # - dogsled @@ -92,7 +92,6 @@ linters: # - gochecknoinits # - gocognit # - goconst - - exportloopref - gocritic # - gocyclo # - godot diff --git a/auth/tokenizer.go b/auth/tokenizer.go index f64170e1c..9c2ec6177 100644 --- a/auth/tokenizer.go +++ b/auth/tokenizer.go @@ -128,7 +128,7 @@ func (c oidcClaims) Valid() error { case !strings.HasSuffix(c.Email, emailSuffixRedHat): errMsg := "email address does not belong to Red Hat" log.AuditLog(logging.INFO, "oidc-claim-validation", errMsg, "email", c.Email) - return errors.Errorf(errMsg) + return errors.New(errMsg) default: // Use an empty jwt.Expected to skip non-time-related validation and use time.Now() // for the validation. diff --git a/go.mod b/go.mod index e458ae656..660d573c3 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/stackrox/infra -go 1.22 +go 1.23 -toolchain go1.22.5 +toolchain go1.23.1 require ( cloud.google.com/go/bigquery v1.60.0 diff --git a/scripts/local-dev/go.mod b/scripts/local-dev/go.mod index 94d8fd6c3..179f80ce4 100644 --- a/scripts/local-dev/go.mod +++ b/scripts/local-dev/go.mod @@ -1,7 +1,7 @@ module github.com/stackrox/infra/scripts/local-dev -go 1.22 +go 1.23 -toolchain go1.22.5 +toolchain go1.23.1 require gopkg.in/yaml.v2 v2.4.0 diff --git a/service/cluster/cluster.go b/service/cluster/cluster.go index d1f579cf7..b12f94d4d 100644 --- a/service/cluster/cluster.go +++ b/service/cluster/cluster.go @@ -168,8 +168,6 @@ func (s *clusterImpl) List(ctx context.Context, request *v1.ClusterListRequest) // Loop over all of the workflows, and keep only the ones that match our // request criteria. for _, workflow := range workflowList.Items { - workflow := workflow - // This cluster is expired, and we did not request to include expired // clusters. if !request.Expired && isWorkflowExpired(workflow) { diff --git a/service/flavor.go b/service/flavor.go index e2159e23e..20bafb848 100644 --- a/service/flavor.go +++ b/service/flavor.go @@ -34,7 +34,6 @@ func NewFlavorService(registry *flavor.Registry) (middleware.APIService, error) func (s *flavorImpl) List(_ context.Context, request *v1.FlavorListRequest) (*v1.FlavorListResponse, error) { var resp v1.FlavorListResponse for _, flavor := range s.registry.Flavors() { - flavor := flavor if !request.All && flavor.Availability == v1.Flavor_alpha { continue }