Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
c38ca4c65808fcb2158b2fcbd93763bf41f0d5c8d027ebbbe68a8b2c31e233b08502142fc15a6d5bbb943c4788a321aff9216bedc5abbbfc65237e78f98106d110697c014ec17a47e812f09e17f443ad302091c1cd030a14a7a54154cab4706908e0e62ed7afbf90f3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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 | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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 !