Skip to content

Commit

Permalink
chore: update golangci-lint (#225)
Browse files Browse the repository at this point in the history
* chore(golangci): remove `go` version as it would default to go version in `go.mod`

Signed-off-by: Rui Chen <[email protected]>

* chore: replace deprecated `exportloopref` with `copyloopvar`

```
WARN The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar.
```

Signed-off-by: Rui Chen <[email protected]>

* chore: remove redundant loop variable copies in tests per `copyloopvar` linter

Signed-off-by: Rui Chen <[email protected]>

---------

Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 authored Jan 14, 2025
1 parent 6f81570 commit 56532f6
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 51 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
run:
go: "1.21"
issues-exit-code: 1
timeout: 5m

Expand Down Expand Up @@ -54,13 +53,13 @@ linters:
- bidichk
- bodyclose
- contextcheck
- copyloopvar
- decorder
- dogsled
- dupl
- errcheck
- errname
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- gci
Expand Down
6 changes: 0 additions & 6 deletions internal/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ func TestNewHelper(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -129,8 +127,6 @@ func TestProcessOutput(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -204,8 +200,6 @@ func TestIsPath(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 0 additions & 6 deletions internal/traverse/traverse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ func TestYamlDockerfiles(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -155,8 +153,6 @@ func TestTraverse(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -234,8 +230,6 @@ func TestIsYAMLOrDockerfile(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
8 changes: 0 additions & 8 deletions pkg/replacer/actions/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestSetAndGetRegex(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -74,7 +73,6 @@ func TestReplaceLocalPath(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -104,7 +102,6 @@ func TestReplaceExcludedPath(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -131,7 +128,6 @@ func TestConvertToEntityRef(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -160,7 +156,6 @@ func TestIsLocal(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -184,7 +179,6 @@ func TestShouldExclude(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -208,7 +202,6 @@ func TestParseActionReference(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -306,7 +299,6 @@ func TestGetChecksum(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
7 changes: 0 additions & 7 deletions pkg/replacer/image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestNewParser(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
parser := New()
Expand All @@ -43,7 +42,6 @@ func TestSetCache(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
parser := New()
Expand All @@ -64,7 +62,6 @@ func TestSetAndGetRegex(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
parser := New()
Expand Down Expand Up @@ -141,7 +138,6 @@ func TestReplaceExcludedPath(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
_, err := parser.Replace(ctx, tt.matchedLine, nil, cfg)
Expand Down Expand Up @@ -171,7 +167,6 @@ func TestConvertToEntityRef(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ref, err := parser.ConvertToEntityRef(tt.reference)
Expand Down Expand Up @@ -219,7 +214,6 @@ func TestGetImageDigestFromRef(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := GetImageDigestFromRef(ctx, tt.refstr, "", nil)
Expand Down Expand Up @@ -253,7 +247,6 @@ func TestShouldSkipImage(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
13 changes: 0 additions & 13 deletions pkg/replacer/replacer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func TestReplacer_ParseContainerImageString(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -394,7 +393,6 @@ func TestReplacer_ParseGitHubActionString(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -719,7 +717,6 @@ CMD ["dex", "serve", "/etc/dex/config.docker.yaml"]
}

for _, tt := range testCases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -948,7 +945,6 @@ jobs:
},
}
for _, tt := range testCases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -994,7 +990,6 @@ func TestReplacer_NewGitHubActionsReplacer(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
r := NewGitHubActionsReplacer(tt.cfg)
Expand All @@ -1017,7 +1012,6 @@ func TestReplacer_NewContainerImagesReplacer(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
r := NewContainerImagesReplacer(tt.cfg)
Expand All @@ -1040,7 +1034,6 @@ func TestReplacer_WithGitHubClient(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
r = r.WithGitHubClientFromToken(tt.token)
Expand All @@ -1062,7 +1055,6 @@ func TestReplacer_WithUserRegex(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
r = r.WithUserRegex(tt.regex)
Expand All @@ -1082,7 +1074,6 @@ func TestReplacer_WithCacheDisabled(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
r = r.WithCacheDisabled()
Expand All @@ -1106,7 +1097,6 @@ func TestReplacer_ParsePathInFS(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
_, err := r.ParsePathInFS(context.Background(), fs, tt.base)
Expand All @@ -1133,7 +1123,6 @@ func TestReplacer_ListPathInFS(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
_, err := r.ListPathInFS(fs, tt.base)
Expand Down Expand Up @@ -1286,7 +1275,6 @@ spec:
},
}
for _, tt := range testCases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
r := NewContainerImagesReplacer(&config.Config{})
Expand Down Expand Up @@ -1441,7 +1429,6 @@ jobs:
},
}
for _, tt := range testCases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
r := NewGitHubActionsReplacer(&config.Config{}).WithGitHubClientFromToken(os.Getenv(cli.GitHubTokenEnvKey))
Expand Down
6 changes: 1 addition & 5 deletions pkg/utils/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func TestFromCommand(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -129,7 +127,7 @@ images:
exclude_images:
- notthisone
exclude_tags:
- notthistag
- notthistag
`,
},
expectedResult: &Config{
Expand Down Expand Up @@ -157,8 +155,6 @@ images:
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/utils/ghrest/ghrest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ func TestClientFunctions(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

if tt.mockResponse != nil {
defer gock.Off()
//gock.DisableNetworking()
Expand Down
2 changes: 0 additions & 2 deletions pkg/utils/store/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ func TestCacher(t *testing.T) {
}

for _, tt := range testCases {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 56532f6

Please sign in to comment.