Skip to content

Conversation

@silvin-lubecki
Copy link
Contributor

- 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)
image

…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]>
…dition: non-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]>
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]>
…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]>
… `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]>
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@5bbb56b). Click here to learn what that means.
The diff coverage is 33.33%.

@@           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
Copy link
Contributor

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?

Copy link
Collaborator

@vdemeester vdemeester left a 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
Copy link
Collaborator

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
Copy link
Collaborator

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 {
Copy link
Collaborator

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 😓

Copy link
Member

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)

Copy link
Member

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is unparam needed ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createTestTempDir - prefix always receives "builder-context-test"

I guess instead, we could change one test here as well

@thaJeztah thaJeztah mentioned this pull request Apr 11, 2019
@@ -1,18 +1,15 @@
FROM golang:1.12.1-alpine
FROM golang:1.12.1 as build
Copy link
Member

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

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM golang:1.12.1-alpine as lint
FROM golang:1.12.1-alpine AS lint

return value, nil
}

// nolint: unparam
Copy link
Member

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;

Func func(interface{}) (interface{}, error)
}
func createTransformHook(additionalTransformers ...Transformer) mapstructure.DecodeHookFuncType {

return image
}

//nolint: unparam
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withNotaryPassphrase - pwd always 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createTestTempDir - prefix always receives "builder-context-test"

I guess instead, we could change one test here as well

@thaJeztah
Copy link
Member

ping @silvin-lubecki 🤗 (also looks like it needs a rebase)

@thaJeztah
Copy link
Member

ping @silvin-lubecki 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants