-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Replace gometalinter with Golangci lint #1797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c38ca4c
65808fc
b2158b2
fcbd937
63bf41f
0d5c8d0
27ebbbe
68a8b2c
31e233b
0850214
2fc15a6
d5bbb94
3c4788a
321aff9
216bedc
5abbbfc
65237e7
8f98106
d110697
c014ec1
7a47e81
2f09e17
f443ad3
02091c1
cd030a1
4a7a541
54cab47
06908e0
e62ed7a
fbf90f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| run: | ||
| deadline: 3m | ||
| skip-dirs: | ||
| - cli/command/stack/kubernetes/api/openapi | ||
| - cli/command/stack/kubernetes/api/client | ||
| skip-files: | ||
| - cli/compose/schema/bindata.go | ||
| - .*generated.* | ||
| - parameter .* always receives | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this in the right section?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 |
||
| linters: | ||
| disable-all: true | ||
| enable: | ||
| - deadcode | ||
| - gocyclo | ||
| - gofmt | ||
| - goimports | ||
| - golint | ||
| - gosimple | ||
| - ineffassign | ||
| - interfacer | ||
| - lll | ||
| - misspell | ||
| - nakedret | ||
| - unconvert | ||
| - unparam | ||
| - unused | ||
| - vet | ||
| linters-settings: | ||
| nakedret: | ||
| command: nakedret | ||
| pattern: ^(?P<path>.*?\\.go):(?P<line>\\d+)\\s*(?P<message>.*)$ | ||
| gocyclo: | ||
| min-complexity: 16 | ||
| lll: | ||
| line-length: 200 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "io" | ||
| "net/http/httputil" | ||
|
|
||
| "github.com/docker/cli/cli" | ||
| "github.com/docker/cli/cli/command" | ||
|
|
@@ -103,10 +102,7 @@ func runAttach(dockerCli command.Cli, opts *attachOptions) error { | |
| } | ||
|
|
||
| resp, errAttach := client.ContainerAttach(ctx, opts.container, options) | ||
| if errAttach != nil && errAttach != httputil.ErrPersistEOF { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand that change 😓
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The That said; the cli could connect to an older daemon that still returns this error, so I think we should change these to an moby/moby@fd65fed (updated in moby/moby@5f47cef)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, actually; so that moby change is the exact path we're hitting here in the |
||
| // ContainerAttach returns an ErrPersistEOF (connection closed) | ||
| // means server met an error and put it in Hijacked connection | ||
| // keep the error and read detailed error message from hijacked connection later | ||
| if errAttach != nil { | ||
| return errAttach | ||
| } | ||
| defer resp.Close() | ||
|
|
@@ -142,10 +138,6 @@ func runAttach(dockerCli command.Cli, opts *attachOptions) error { | |
| return err | ||
| } | ||
|
|
||
| if errAttach != nil { | ||
| return errAttach | ||
| } | ||
|
|
||
| return getExitStatus(errC, resultC) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "io" | ||
| "net/http/httputil" | ||
| "os" | ||
| "runtime" | ||
| "strings" | ||
|
|
@@ -253,10 +252,7 @@ func attachContainer( | |
| } | ||
|
|
||
| resp, errAttach := dockerCli.Client().ContainerAttach(ctx, containerID, options) | ||
| if errAttach != nil && errAttach != httputil.ErrPersistEOF { | ||
| // ContainerAttach returns an ErrPersistEOF (connection closed) | ||
| // means server met an error and put it in Hijacked connection | ||
| // keep the error and read detailed error message from hijacked connection later | ||
| if errAttach != nil { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| return nil, errAttach | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "io" | ||
| "net/http/httputil" | ||
| "strings" | ||
|
|
||
| "github.com/docker/cli/cli" | ||
|
|
@@ -98,10 +97,7 @@ func runStart(dockerCli command.Cli, opts *startOptions) error { | |
| } | ||
|
|
||
| resp, errAttach := dockerCli.Client().ContainerAttach(ctx, c.ID, options) | ||
| if errAttach != nil && errAttach != httputil.ErrPersistEOF { | ||
| // ContainerAttach return an ErrPersistEOF (connection closed) | ||
| // means server met an error and already put it in Hijacked connection, | ||
| // we would keep the error and read the detailed error message from hijacked connection | ||
| if errAttach != nil { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
| return errAttach | ||
| } | ||
| defer resp.Close() | ||
|
|
@@ -154,7 +150,7 @@ func runStart(dockerCli command.Cli, opts *startOptions) error { | |
| } | ||
| } | ||
| if attachErr := <-cErr; attachErr != nil { | ||
| if _, ok := err.(term.EscapeError); ok { | ||
| if _, ok := attachErr.(term.EscapeError); ok { | ||
| // The user entered the detach escape sequence. | ||
| return nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,12 +24,12 @@ var prepareEmpty = func(t *testing.T) (string, func()) { | |
| } | ||
|
|
||
| var prepareNoFiles = func(t *testing.T) (string, func()) { | ||
| return createTestTempDir(t, "", "builder-context-test") | ||
| return createTestTempDir(t, "builder-context-test") | ||
| } | ||
|
|
||
| var prepareOneFile = func(t *testing.T) (string, func()) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents) | ||
| return contextDir, cleanup | ||
| } | ||
|
|
||
|
|
@@ -42,15 +42,15 @@ func testValidateContextDirectory(t *testing.T, prepare func(t *testing.T) (stri | |
| } | ||
|
|
||
| func TestGetContextFromLocalDirNoDockerfile(t *testing.T) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| defer cleanup() | ||
|
|
||
| _, _, err := GetContextFromLocalDir(contextDir, "") | ||
| assert.ErrorContains(t, err, "Dockerfile") | ||
| } | ||
|
|
||
| func TestGetContextFromLocalDirNotExistingDir(t *testing.T) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| defer cleanup() | ||
|
|
||
| fakePath := filepath.Join(contextDir, "fake") | ||
|
|
@@ -60,7 +60,7 @@ func TestGetContextFromLocalDirNotExistingDir(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetContextFromLocalDirNotExistingDockerfile(t *testing.T) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| defer cleanup() | ||
|
|
||
| fakePath := filepath.Join(contextDir, "fake") | ||
|
|
@@ -70,10 +70,10 @@ func TestGetContextFromLocalDirNotExistingDockerfile(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) { | ||
| contextDir, dirCleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, dirCleanup := createTestTempDir(t, "builder-context-test") | ||
| defer dirCleanup() | ||
|
|
||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) | ||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents) | ||
|
|
||
| chdirCleanup := chdir(t, contextDir) | ||
| defer chdirCleanup() | ||
|
|
@@ -86,10 +86,10 @@ func TestGetContextFromLocalDirWithNoDirectory(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetContextFromLocalDirWithDockerfile(t *testing.T) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| defer cleanup() | ||
|
|
||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) | ||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents) | ||
|
|
||
| absContextDir, relDockerfile, err := GetContextFromLocalDir(contextDir, "") | ||
| assert.NilError(t, err) | ||
|
|
@@ -99,11 +99,11 @@ func TestGetContextFromLocalDirWithDockerfile(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetContextFromLocalDirLocalFile(t *testing.T) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| defer cleanup() | ||
|
|
||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) | ||
| testFilename := createTestTempFile(t, contextDir, "tmpTest", "test", 0777) | ||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents) | ||
| testFilename := createTestTempFile(t, contextDir, "tmpTest", "test") | ||
|
|
||
| absContextDir, relDockerfile, err := GetContextFromLocalDir(testFilename, "") | ||
|
|
||
|
|
@@ -121,13 +121,13 @@ func TestGetContextFromLocalDirLocalFile(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetContextFromLocalDirWithCustomDockerfile(t *testing.T) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| defer cleanup() | ||
|
|
||
| chdirCleanup := chdir(t, contextDir) | ||
| defer chdirCleanup() | ||
|
|
||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) | ||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents) | ||
|
|
||
| absContextDir, relDockerfile, err := GetContextFromLocalDir(contextDir, DefaultDockerfileName) | ||
| assert.NilError(t, err) | ||
|
|
@@ -173,10 +173,10 @@ func TestGetContextFromReaderString(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetContextFromReaderTar(t *testing.T) { | ||
| contextDir, cleanup := createTestTempDir(t, "", "builder-context-test") | ||
| contextDir, cleanup := createTestTempDir(t, "builder-context-test") | ||
| defer cleanup() | ||
|
|
||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents, 0777) | ||
| createTestTempFile(t, contextDir, DefaultDockerfileName, dockerfileContents) | ||
|
|
||
| tarStream, err := archive.Tar(contextDir, archive.Uncompressed) | ||
| assert.NilError(t, err) | ||
|
|
@@ -241,17 +241,18 @@ func TestValidateContextDirectoryWithOneFileExcludes(t *testing.T) { | |
| // createTestTempDir creates a temporary directory for testing. | ||
| // It returns the created path and a cleanup function which is meant to be used as deferred call. | ||
| // When an error occurs, it terminates the test. | ||
| func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) { | ||
| path, err := ioutil.TempDir(dir, prefix) | ||
| //nolint: unparam | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I guess instead, we could change one test here as well |
||
| func createTestTempDir(t *testing.T, prefix string) (string, func()) { | ||
| path, err := ioutil.TempDir("", prefix) | ||
| assert.NilError(t, err) | ||
| return path, func() { assert.NilError(t, os.RemoveAll(path)) } | ||
| } | ||
|
|
||
| // createTestTempFile creates a temporary file within dir with specific contents and permissions. | ||
| // When an error occurs, it terminates the test | ||
| func createTestTempFile(t *testing.T, dir, filename, contents string, perm os.FileMode) string { | ||
| func createTestTempFile(t *testing.T, dir, filename, contents string) string { | ||
| filePath := filepath.Join(dir, filename) | ||
| err := ioutil.WriteFile(filePath, []byte(contents), perm) | ||
| err := ioutil.WriteFile(filePath, []byte(contents), 0777) | ||
| assert.NilError(t, err) | ||
| return filePath | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice !