Merge pull request #3411 from mxpv/linter

Switch from gometalinter to golangci-lint
This commit is contained in:
Michael Crosby 2019-07-15 10:58:59 -04:00 committed by GitHub
commit f3e148b1cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 34 additions and 37 deletions

21
.golangci.yml Normal file
View File

@ -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

View File

@ -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"
]
}

View File

@ -121,7 +121,7 @@ all: binaries
check: proto-fmt ## run all linters check: proto-fmt ## run all linters
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
gometalinter --config .gometalinter.json ./... golangci-lint run
ci: check binaries checkprotos coverage coverage-integration ## to be used by the CI ci: check binaries checkprotos coverage coverage-integration ## to be used by the CI

View File

@ -19,7 +19,7 @@
package main package main
import ( 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" "github.com/containerd/containerd/runtime/v2/shim"
) )

View File

@ -19,7 +19,7 @@
package main package main
import ( 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" "github.com/containerd/containerd/runtime/v2/shim"
) )

View File

@ -47,7 +47,7 @@ var Command = cli.Command{
var e *events.Envelope var e *events.Envelope
select { select {
case e = <-eventsCh: case e = <-eventsCh:
case err, open = <-errCh: case err = <-errCh:
return err return err
} }
if e != nil { if e != nil {

View File

@ -27,7 +27,7 @@ import (
"github.com/containerd/containerd/api/types" "github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/platforms" "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" "github.com/urfave/cli"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
) )

View File

@ -91,7 +91,7 @@ func familiarizeReference(ref string) (string, error) {
func ociReferenceName(name string) string { func ociReferenceName(name string) string {
// OCI defines the reference name as only a tag excluding the // OCI defines the reference name as only a tag excluding the
// repository. The containerd annotation contains the full image name // 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 // image
var ociRef string var ociRef string
if spec, err := reference.Parse(name); err == nil { if spec, err := reference.Parse(name); err == nil {

View File

@ -19,6 +19,6 @@ package progress
const ( const (
escape = "\x1b" escape = "\x1b"
reset = escape + "[0m" reset = escape + "[0m"
red = escape + "[31m" // nolint: staticcheck, varcheck red = escape + "[31m" // nolint: deadcode, varcheck, unused
green = escape + "[32m" green = escape + "[32m"
) )

View File

@ -87,7 +87,7 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
defer f.Close() defer f.Close()
if _, err := io.Copy(os.Stderr, f); err != nil { if _, err := io.Copy(os.Stderr, f); err != nil {
// When using a multi-container shim the 2nd to Nth container in the // 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. // message here when the shim connect times out.
if !os.IsNotExist(errors.Cause(err)) { if !os.IsNotExist(errors.Cause(err)) {
log.G(ctx).WithError(err).Error("copy shim log") log.G(ctx).WithError(err).Error("copy shim log")

View File

@ -261,7 +261,7 @@ func (c *Container) Process(id string) (process.Process, error) {
// ReserveProcess checks for the existence of an id and atomically // ReserveProcess checks for the existence of an id and atomically
// reserves the process id if it does not already exist // 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 // cancel func to release the reservation
func (c *Container) ReserveProcess(id string) (bool, func()) { func (c *Container) ReserveProcess(id string) (bool, func()) {
c.mu.Lock() c.mu.Lock()

View File

@ -79,7 +79,7 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
defer f.Close() defer f.Close()
if _, err := io.Copy(os.Stderr, f); err != nil { if _, err := io.Copy(os.Stderr, f); err != nil {
// When using a multi-container shim the 2nd to Nth container in the // 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. // message here when the shim connect times out.
if !os.IsNotExist(errors.Cause(err)) { if !os.IsNotExist(errors.Cause(err)) {
log.G(ctx).WithError(err).Error("copy shim log") log.G(ctx).WithError(err).Error("copy shim log")

View File

@ -21,6 +21,5 @@
set -eu -o pipefail set -eu -o pipefail
go get -u github.com/stevvooe/protobuild go get -u github.com/stevvooe/protobuild
go get -u github.com/alecthomas/gometalinter go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
gometalinter --install >/dev/null
go get -u github.com/cpuguy83/go-md2man go get -u github.com/cpuguy83/go-md2man

View File

@ -43,7 +43,7 @@ import (
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/runtime/linux/runctypes" "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/runtime/v2/runc/options"
"github.com/containerd/containerd/services" "github.com/containerd/containerd/services"
"github.com/containerd/typeurl" "github.com/containerd/typeurl"

View File

@ -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) { func (t *task) Process(ctx context.Context, id string) (p runtime.Process, err error) {
p = t.getProcess(id) p = t.getProcess(id)
if p == nil { if p == nil { // nolint: govet
err = errors.Wrapf(errdefs.ErrNotFound, "no such process %s", id) err = errors.Wrapf(errdefs.ErrNotFound, "no such process %s", id)
} }