-
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
Conversation
…taticcheck) Signed-off-by: Silvin Lubecki <[email protected]>
…of append is never used, except maybe in other appends (staticcheck) Signed-off-by: Silvin Lubecki <[email protected]>
…the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (staticcheck) Signed-off-by: Silvin Lubecki <[email protected]>
…check) Signed-off-by: Silvin Lubecki <[email protected]>
…n: nil != nil (govet) Signed-off-by: Silvin Lubecki <[email protected]>
…dition: non-nil != nil (govet) Signed-off-by: Silvin Lubecki <[email protected]>
…pe assertion (govet) Signed-off-by: Silvin Lubecki <[email protected]>
…nil != nil (govet) Signed-off-by: Silvin Lubecki <[email protected]>
…,inline", json:"-"` not compatible with reflect.StructTag.Get: key:"value" pairs not separated by spaces (govet) Signed-off-by: Silvin Lubecki <[email protected]>
…/github.com/docker/go-units.Ulimit` composite literal uses unkeyed fields (govet) Signed-off-by: Silvin Lubecki <[email protected]>
…: nil != nil (govet) Signed-off-by: Silvin Lubecki <[email protected]>
Signed-off-by: Silvin Lubecki <[email protected]>
… `dir` always receives `""` (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…- `perm` always receives `0777` (`511`) (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…r) is always nil (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
… 1 (error) is always nil (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…sed (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…ces` - `stackName` always receives `"test"` (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…error) is always nil (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…rror) is always nil (unparam) cli/compose/convert/service.go:538:110: convertEndpointSpec - result 1 (error) is always nil (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…se function signatures cli/compose/loader/loader.go:756:66: transformServiceNetworkMap - result 1 (error) is always nil (unparam) cli/compose/loader/loader.go:767:67: transformStringOrNumberList - result 1 (error) is always nil (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
… `s` is unused (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…always receives `"argument"` (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…sphrase` - `pwd` always receives `"foo"` (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…ert) Signed-off-by: Silvin Lubecki <[email protected]>
Signed-off-by: Silvin Lubecki <[email protected]>
…nconvert) Signed-off-by: Silvin Lubecki <[email protected]>
…onvert) Signed-off-by: Silvin Lubecki <[email protected]>
… `prefix` always receives `"builder-context-test"` (unparam) Signed-off-by: Silvin Lubecki <[email protected]>
…lmost the same configuration. Signed-off-by: Silvin Lubecki <[email protected]>
0bb59c4 to
fbf90f3
Compare
Codecov Report
@@ Coverage Diff @@
## master #1797 +/- ##
========================================
Coverage ? 56.3%
========================================
Files ? 308
Lines ? 21284
Branches ? 0
========================================
Hits ? 11983
Misses ? 8430
Partials ? 871 |
| skip-files: | ||
| - cli/compose/schema/bindata.go | ||
| - .*generated.* | ||
| - parameter .* always receives |
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.
Is this in the right section?
vdemeester
left a comment
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.
Few question, otherwise looks good 👍
| @@ -0,0 +1,35 @@ | |||
| run: | |||
| deadline: 3m | |||
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 !
| skip-files: | ||
| - cli/compose/schema/bindata.go | ||
| - .*generated.* | ||
| - parameter .* always receives |
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.
🤔
| } | ||
|
|
||
| resp, errAttach := client.ContainerAttach(ctx, opts.container, options) | ||
| if errAttach != nil && errAttach != httputil.ErrPersistEOF { |
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.
I don't understand that change 😓
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.
The httputil.ErrPersistEOF is no longer used, so should no longer be returned by anything.
That said; the cli could connect to an older daemon that still returns this error, so I think we should change these to an //nolint, which is what we did in the engine;
//nolint:staticcheck // ignore SA1019 for connecting to old (pre go1.8) daemons
moby/moby@fd65fed (updated in moby/moby@5f47cef)
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.
Oh, actually; so that moby change is the exact path we're hitting here in the ContainerAttach, so the client won't return a httputil.ErrPersistEOF error, so we can safely remove that condition here.
| // 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 { |
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.
Same here
| // 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 { |
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.
and here
| // 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 |
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.
Why is unparam needed ?
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.
createTestTempDir-prefixalways receives"builder-context-test"
I guess instead, we could change one test here as well
| @@ -1,18 +1,15 @@ | |||
| FROM golang:1.12.1-alpine | |||
| FROM golang:1.12.1 as build | |||
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.
alpine doesn't work for this one? 😢
nit: could you use capital AS ? Trying to keep Dockerfile keywords consistently cased
| FROM golang:1.12.1 as build | |
| FROM golang:1.12.1 AS build |
| go build -v -o /usr/local/bin/gometalinter . && \ | ||
| gometalinter --install && \ | ||
| rm -rf /go/src/* /go/pkg/* | ||
| FROM golang:1.12.1-alpine as lint |
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.
| FROM golang:1.12.1-alpine as lint | |
| FROM golang:1.12.1-alpine AS lint |
| return value, nil | ||
| } | ||
|
|
||
| // nolint: unparam |
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.
Wonder if it would be smart enough to accept it if we'd define a type for this;
cli/cli/compose/loader/loader.go
Lines 290 to 293 in 9a39a10
| Func func(interface{}) (interface{}, error) | |
| } | |
| func createTransformHook(additionalTransformers ...Transformer) mapstructure.DecodeHookFuncType { |
| return image | ||
| } | ||
|
|
||
| //nolint: unparam |
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.
withNotaryPassphrase-pwdalways receives"foo"
perhaps we should change one test to use a different value 😅
| // 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 |
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.
createTestTempDir-prefixalways receives"builder-context-test"
I guess instead, we could change one test here as well
|
ping @silvin-lubecki 🤗 (also looks like it needs a rebase) |
|
ping @silvin-lubecki 🤗 |
- What I did
gometalinter is deprecated in favour og golangci-lint which is faster and less memory hungry.
https://github.com/golangci/golangci-lint has more on the performance etc.
All the caught issues were fixed, commit by commit for better review. Happy to squash everything at the end of the review 👍
Moved the linter Dockerfile to Multistage build.
- A picture of a cute animal (not mandatory but encouraged)
