Skip to content

Commit

Permalink
Update golangci-lint to 1.59.x and fix linting
Browse files Browse the repository at this point in the history
This mainly removing the need to copy variable in a for loop to
capture rang as it is now "fixed" in go 1.22+.

> The copy of the 'for' variable "td" can be deleted (Go
1.22+) (copyloopvar)

This also fixes some fatcontext issues, for loop range, …

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester committed Jun 10, 2024
1 parent 274035d commit 47f940a
Show file tree
Hide file tree
Showing 45 changed files with 679 additions and 616 deletions.
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- err113
- gofumpt
- gomnd
- gomoddirectives
- ireturn
- lll
- mnd
- nestif
- nlreturn
- nonamedreturns
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TESTPKGS = $(shell env GO111MODULE=on $(GO) list -f \
BIN = $(CURDIR)/.bin
WOKE ?= go run -modfile go.mod github.com/get-woke/woke

GOLANGCI_VERSION = v1.57.2
GOLANGCI_VERSION = v1.59.1
WOKE_VERSION = v0.19.0

GO = go
Expand Down
11 changes: 4 additions & 7 deletions internal/sidecarlogresults/sidecarlogresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ import (
)

// ErrSizeExceeded indicates that the result exceeded its maximum allowed size
var ErrSizeExceeded = errors.New("results size exceeds configured limit")
var stepDir = pipeline.StepsDir
var (
ErrSizeExceeded = errors.New("results size exceeds configured limit")
stepDir = pipeline.StepsDir
)

type SidecarLogResultType string

Expand Down Expand Up @@ -146,8 +148,6 @@ func LookForResults(w io.Writer, runDir string, resultsDir string, resultNames [
results := make(chan SidecarLogResult)
g := new(errgroup.Group)
for _, resultFile := range resultNames {
resultFile := resultFile

g.Go(func() error {
newResult, err := readResults(resultsDir, resultFile, "", taskResultType)
if err != nil {
Expand All @@ -162,10 +162,7 @@ func LookForResults(w io.Writer, runDir string, resultsDir string, resultNames [
}

for sName, sresults := range stepResults {
sresults := sresults
sName := sName
for _, resultName := range sresults {
resultName := resultName
stepResultsDir := filepath.Join(stepResultsDir, sName, "results")

g.Go(func() error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/config/feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func TestIsSpireEnabled(t *testing.T) {
Data: tc.configmap,
}
store.OnConfigChanged(featureflags)
ctx = store.ToContext(ctx)
ctx := store.ToContext(ctx)
got := config.IsSpireEnabled(ctx)

if tc.want != got {
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func MergeStepsWithSpecs(steps []Step, overrides []TaskRunStepSpec) ([]Step, err
stepNameToOverride[o.Name] = o
}
for i, s := range steps {
s := s
o, found := stepNameToOverride[s.Name]
if !found {
continue
Expand All @@ -108,7 +107,6 @@ func MergeSidecarsWithSpecs(sidecars []Sidecar, overrides []TaskRunSidecarSpec)
sidecarNameToOverride[o.Name] = o
}
for i, s := range sidecars {
s := s
o, found := sidecarNameToOverride[s.Name]
if !found {
continue
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/pipeline/v1/param_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ type ParamValuesHolder struct {
AOrS v1.ParamValue `json:"val"`
}

//nolint:musttag
func TestParamValues_UnmarshalJSON(t *testing.T) {
cases := []struct {
input map[string]interface{}
Expand Down Expand Up @@ -399,7 +398,6 @@ func TestParamValues_UnmarshalJSON_Directly(t *testing.T) {
}
}

//nolint:musttag
func TestParamValues_UnmarshalJSON_Error(t *testing.T) {
cases := []struct {
desc string
Expand All @@ -417,7 +415,6 @@ func TestParamValues_UnmarshalJSON_Error(t *testing.T) {
}
}

//nolint:musttag
func TestParamValues_MarshalJSON(t *testing.T) {
cases := []struct {
input v1.ParamValue
Expand Down
Loading

0 comments on commit 47f940a

Please sign in to comment.