Skip to content

fix: resolve golangci-lint exclusions — QF1012 WriteString+Sprintf style issues #524

@tekenstam

Description

@tekenstam

Background

When golangci-lint v2 was introduced as part of the deps update in #521, two categories of pre-existing staticcheck issues were suppressed in `.golangci.yml`:

  1. SA1019 — aws-sdk-go v1 deprecation warnings — tracked in feat: migrate from aws-sdk-go v1 to aws-sdk-go-v2 #523 (migrate to v2 SDK)
  2. QF1012 — `WriteString(fmt.Sprintf(...))` style issues — tracked here

Once #523 is resolved, the SA1019 exclusion can also be removed.


QF1012 Issues to Fix

`controllers/provisioners/eks/helpers.go`:

Line Current Fix
621 `sb.WriteString(fmt.Sprintf("-Base64ClusterCA %v ", aws.StringValue(state.Cluster.CertificateAuthority.Data)))` `fmt.Fprintf(&sb, "-Base64ClusterCA %v ", aws.StringValue(...))`
622 `sb.WriteString(fmt.Sprintf("-APIServerEndpoint %v ", aws.StringValue(state.Cluster.Endpoint)))` `fmt.Fprintf(&sb, "-APIServerEndpoint %v ", aws.StringValue(...))`
625 `sb.WriteString(fmt.Sprintf("-ContainerRuntime %v ", bootstrapOptions.ContainerRuntime))` `fmt.Fprintf(&sb, "-ContainerRuntime %v ", bootstrapOptions.ContainerRuntime)`
627 `sb.WriteString(fmt.Sprintf("-KubeletExtraArgs '%v'", ctx.GetKubeletExtraArgs()))` `fmt.Fprintf(&sb, "-KubeletExtraArgs '%v'", ctx.GetKubeletExtraArgs())`

Note: `fmt.Fprintf` writes directly to the `strings.Builder` without allocating an intermediate string.


Definition of Done

  • All 4 QF1012 occurrences in `helpers.go` are rewritten using `fmt.Fprintf`
  • The `QF1012` rule is removed from `.golangci.yml`
  • The `SA1019` rule is removed from `.golangci.yml` as part of the v2 SDK migration (feat: migrate from aws-sdk-go v1 to aws-sdk-go-v2 #523)
  • `golangci-lint run ./...` passes with no exclusion rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions