Skip to content

Commit 743c385

Browse files
authored
Merge pull request #6862 from thaJeztah/update_golangci_lint_config
fix linting and update golangci-lint config
2 parents 434193f + dc4abf8 commit 743c385

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

.golangci.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,6 @@ linters:
158158
- name: use-any # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#use-any
159159
- name: use-errors-new # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#use-errors-new
160160

161-
usetesting:
162-
os-chdir: false # FIXME(thaJeztah): Disable `os.Chdir()` detections; should be automatically disabled on Go < 1.24; see https://github.com/docker/cli/pull/5835#issuecomment-2665302478
163-
context-background: false # FIXME(thaJeztah): Disable `context.Background()` detections; should be automatically disabled on Go < 1.24; see https://github.com/docker/cli/pull/5835#issuecomment-2665302478
164-
context-todo: false # FIXME(thaJeztah): Disable `context.TODO()` detections; should be automatically disabled on Go < 1.24; see https://github.com/docker/cli/pull/5835#issuecomment-2665302478
165-
166161
exclusions:
167162
# We prefer to use an "linters.exclusions.rules" so that new "default" exclusions are not
168163
# automatically inherited. We can decide whether or not to follow upstream
@@ -225,13 +220,10 @@ linters:
225220
linters:
226221
- staticcheck
227222

228-
# Ignore deprecation linting for cli/command/stack/*.
229-
#
230-
# FIXME(thaJeztah): remove exception once these functions are un-exported or internal; see https://github.com/docker/cli/pull/6389
231-
- text: '^(SA1019): '
232-
path: "cli/command/stack"
223+
# TODO(thaJeztah): remove once https://github.com/leighmcculloch/gocheckcompilerdirectives/issues/7 is fixed.
224+
- text: "compiler directive unrecognized: //go:fix"
233225
linters:
234-
- staticcheck
226+
- gocheckcompilerdirectives
235227

236228
# Log a warning if an exclusion rule is unused.
237229
# Default: false

cli/command/image/build/context_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) {
6868
contextDir := createTestTempDir(t)
6969
createTestTempFile(t, contextDir, defaultDockerfileName, dockerfileContents)
7070

71-
chdir(t, contextDir)
71+
t.Chdir(contextDir)
7272

7373
absContextDir, relDockerfile, err := GetContextFromLocalDir(contextDir, "")
7474
assert.NilError(t, err)
@@ -110,7 +110,7 @@ func TestGetContextFromLocalDirLocalFile(t *testing.T) {
110110

111111
func TestGetContextFromLocalDirWithCustomDockerfile(t *testing.T) {
112112
contextDir := createTestTempDir(t)
113-
chdir(t, contextDir)
113+
t.Chdir(contextDir)
114114

115115
createTestTempFile(t, contextDir, defaultDockerfileName, dockerfileContents)
116116

@@ -248,20 +248,6 @@ func createTestTempFile(t *testing.T, dir, filename, contents string) string {
248248
return filePath
249249
}
250250

251-
// chdir changes current working directory to dir.
252-
// It returns a function which changes working directory back to the previous one.
253-
// This function is meant to be executed as a deferred call.
254-
// When an error occurs, it terminates the test.
255-
func chdir(t *testing.T, dir string) {
256-
t.Helper()
257-
workingDirectory, err := os.Getwd()
258-
assert.NilError(t, err)
259-
assert.NilError(t, os.Chdir(dir))
260-
t.Cleanup(func() {
261-
assert.NilError(t, os.Chdir(workingDirectory))
262-
})
263-
}
264-
265251
func TestIsArchive(t *testing.T) {
266252
tests := []struct {
267253
doc string

0 commit comments

Comments
 (0)