From 2b521e25a72a5a480e139f28446c6138cc5adaba Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sun, 14 Jul 2019 19:32:37 -0700 Subject: [PATCH 1/2] Switch to golangci-lint Signed-off-by: Maksym Pavlenko --- .golangci.yml | 21 +++++++++++++++++++++ .gometalinter.json | 23 ----------------------- Makefile | 2 +- script/setup/install-dev-tools | 3 +-- 4 files changed, 23 insertions(+), 26 deletions(-) create mode 100644 .golangci.yml delete mode 100644 .gometalinter.json diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..925763113 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,21 @@ +linters: + enable: + - structcheck + - varcheck + - staticcheck + - unconvert + - gofmt + - goimports + - golint + - ineffassign + - vet + - unused + - misspell + disable: + - errcheck + +run: + skip-dirs: + - api + - design + - docs diff --git a/.gometalinter.json b/.gometalinter.json deleted file mode 100644 index d40138005..000000000 --- a/.gometalinter.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "Vendor": true, - "Deadline": "2m", - "Sort": ["linter", "severity", "path", "line"], - "Exclude": [ - ".*\\.pb\\.go", - "fetch\\.go:.*::error: unrecognized printf verb 'r'" - ], - "EnableGC": true, - - "Enable": [ - "structcheck", - "varcheck", - "staticcheck", - "unconvert", - - "gofmt", - "goimports", - "golint", - "ineffassign", - "vet" - ] -} diff --git a/Makefile b/Makefile index 3d94059e6..0a7f5761e 100644 --- a/Makefile +++ b/Makefile @@ -121,7 +121,7 @@ all: binaries check: proto-fmt ## run all linters @echo "$(WHALE) $@" - gometalinter --config .gometalinter.json ./... + golangci-lint run ci: check binaries checkprotos coverage coverage-integration ## to be used by the CI diff --git a/script/setup/install-dev-tools b/script/setup/install-dev-tools index d49932dd8..fa36c1d6a 100755 --- a/script/setup/install-dev-tools +++ b/script/setup/install-dev-tools @@ -21,6 +21,5 @@ set -eu -o pipefail go get -u github.com/stevvooe/protobuild -go get -u github.com/alecthomas/gometalinter -gometalinter --install >/dev/null +go get -u github.com/golangci/golangci-lint/cmd/golangci-lint go get -u github.com/cpuguy83/go-md2man From ef7f46eb7bff5fad55b108027332a2938f77066a Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sun, 14 Jul 2019 19:32:58 -0700 Subject: [PATCH 2/2] Fix linter errors Signed-off-by: Maksym Pavlenko --- cmd/containerd-shim-runc-v1/main.go | 2 +- cmd/containerd-shim-runc-v2/main.go | 2 +- cmd/ctr/commands/events/events.go | 2 +- cmd/ctr/commands/plugins/plugins.go | 2 +- images/archive/reference.go | 2 +- pkg/progress/escape.go | 2 +- runtime/v2/binary.go | 2 +- runtime/v2/runc/container.go | 2 +- runtime/v2/shim.go | 2 +- services/tasks/local.go | 2 +- windows/task.go | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/containerd-shim-runc-v1/main.go b/cmd/containerd-shim-runc-v1/main.go index b8a8df7b0..1b1b106aa 100644 --- a/cmd/containerd-shim-runc-v1/main.go +++ b/cmd/containerd-shim-runc-v1/main.go @@ -19,7 +19,7 @@ package main import ( - "github.com/containerd/containerd/runtime/v2/runc/v1" + v1 "github.com/containerd/containerd/runtime/v2/runc/v1" "github.com/containerd/containerd/runtime/v2/shim" ) diff --git a/cmd/containerd-shim-runc-v2/main.go b/cmd/containerd-shim-runc-v2/main.go index 2ebe18ce2..4f5d804d9 100644 --- a/cmd/containerd-shim-runc-v2/main.go +++ b/cmd/containerd-shim-runc-v2/main.go @@ -19,7 +19,7 @@ package main import ( - "github.com/containerd/containerd/runtime/v2/runc/v2" + v2 "github.com/containerd/containerd/runtime/v2/runc/v2" "github.com/containerd/containerd/runtime/v2/shim" ) diff --git a/cmd/ctr/commands/events/events.go b/cmd/ctr/commands/events/events.go index 507de4459..9c5934c1c 100644 --- a/cmd/ctr/commands/events/events.go +++ b/cmd/ctr/commands/events/events.go @@ -47,7 +47,7 @@ var Command = cli.Command{ var e *events.Envelope select { case e = <-eventsCh: - case err, open = <-errCh: + case err = <-errCh: return err } if e != nil { diff --git a/cmd/ctr/commands/plugins/plugins.go b/cmd/ctr/commands/plugins/plugins.go index df29441c4..a7f42192c 100644 --- a/cmd/ctr/commands/plugins/plugins.go +++ b/cmd/ctr/commands/plugins/plugins.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/platforms" - "github.com/opencontainers/image-spec/specs-go/v1" + v1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" "google.golang.org/grpc/codes" ) diff --git a/images/archive/reference.go b/images/archive/reference.go index 19f419eaa..cd63517e5 100644 --- a/images/archive/reference.go +++ b/images/archive/reference.go @@ -91,7 +91,7 @@ func familiarizeReference(ref string) (string, error) { func ociReferenceName(name string) string { // OCI defines the reference name as only a tag excluding the // repository. The containerd annotation contains the full image name - // since the tag is insufficent for correctly naming and referring to an + // since the tag is insufficient for correctly naming and referring to an // image var ociRef string if spec, err := reference.Parse(name); err == nil { diff --git a/pkg/progress/escape.go b/pkg/progress/escape.go index 73505f69d..d9ce5b088 100644 --- a/pkg/progress/escape.go +++ b/pkg/progress/escape.go @@ -19,6 +19,6 @@ package progress const ( escape = "\x1b" reset = escape + "[0m" - red = escape + "[31m" // nolint: staticcheck, varcheck + red = escape + "[31m" // nolint: deadcode, varcheck, unused green = escape + "[32m" ) diff --git a/runtime/v2/binary.go b/runtime/v2/binary.go index 2087509ba..22869a25c 100644 --- a/runtime/v2/binary.go +++ b/runtime/v2/binary.go @@ -87,7 +87,7 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_ defer f.Close() if _, err := io.Copy(os.Stderr, f); err != nil { // When using a multi-container shim the 2nd to Nth container in the - // shim will not have a seperate log pipe. Ignore the failure log + // shim will not have a separate log pipe. Ignore the failure log // message here when the shim connect times out. if !os.IsNotExist(errors.Cause(err)) { log.G(ctx).WithError(err).Error("copy shim log") diff --git a/runtime/v2/runc/container.go b/runtime/v2/runc/container.go index 6afa92db2..c9c540065 100644 --- a/runtime/v2/runc/container.go +++ b/runtime/v2/runc/container.go @@ -261,7 +261,7 @@ func (c *Container) Process(id string) (process.Process, error) { // ReserveProcess checks for the existence of an id and atomically // reserves the process id if it does not already exist // -// Returns true if the process id was sucessfully reserved and a +// Returns true if the process id was successfully reserved and a // cancel func to release the reservation func (c *Container) ReserveProcess(id string) (bool, func()) { c.mu.Lock() diff --git a/runtime/v2/shim.go b/runtime/v2/shim.go index a8efdbce3..41f908c3e 100644 --- a/runtime/v2/shim.go +++ b/runtime/v2/shim.go @@ -79,7 +79,7 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt defer f.Close() if _, err := io.Copy(os.Stderr, f); err != nil { // When using a multi-container shim the 2nd to Nth container in the - // shim will not have a seperate log pipe. Ignore the failure log + // shim will not have a separate log pipe. Ignore the failure log // message here when the shim connect times out. if !os.IsNotExist(errors.Cause(err)) { log.G(ctx).WithError(err).Error("copy shim log") diff --git a/services/tasks/local.go b/services/tasks/local.go index 78e384f87..63aff1b8a 100644 --- a/services/tasks/local.go +++ b/services/tasks/local.go @@ -43,7 +43,7 @@ import ( "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime/linux/runctypes" - "github.com/containerd/containerd/runtime/v2" + v2 "github.com/containerd/containerd/runtime/v2" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/containerd/services" "github.com/containerd/typeurl" diff --git a/windows/task.go b/windows/task.go index c2c23aff1..ebcfd789b 100644 --- a/windows/task.go +++ b/windows/task.go @@ -283,7 +283,7 @@ func (t *task) Update(ctx context.Context, resources *types.Any) error { func (t *task) Process(ctx context.Context, id string) (p runtime.Process, err error) { p = t.getProcess(id) - if p == nil { + if p == nil { // nolint: govet err = errors.Wrapf(errdefs.ErrNotFound, "no such process %s", id) }