From 01e1e58adaec1147f6e223791fe1da9d5f026588 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 9 Jun 2017 12:32:14 -0400 Subject: [PATCH] Add unused linter. Signed-off-by: Daniel Nephin --- cli/command/container/stats_helpers.go | 5 ++--- cli/command/formatter/disk_usage.go | 2 -- cli/command/formatter/reflect_test.go | 2 +- cli/command/image/pull_test.go | 19 +++++-------------- cli/command/image/push_test.go | 11 ++--------- cli/command/node/opts.go | 1 - cli/command/registry/login.go | 1 - cli/command/swarm/unlock_test.go | 1 - cli/compose/loader/loader_test.go | 4 ---- dockerfiles/Dockerfile.lint | 3 ++- gometalinter.json | 3 ++- 11 files changed, 14 insertions(+), 38 deletions(-) diff --git a/cli/command/container/stats_helpers.go b/cli/command/container/stats_helpers.go index c6849c805a..eb12cd0dec 100644 --- a/cli/command/container/stats_helpers.go +++ b/cli/command/container/stats_helpers.go @@ -16,9 +16,8 @@ import ( ) type stats struct { - ostype string - mu sync.Mutex - cs []*formatter.ContainerStats + mu sync.Mutex + cs []*formatter.ContainerStats } // daemonOSType is set once we have at least one stat for a container diff --git a/cli/command/formatter/disk_usage.go b/cli/command/formatter/disk_usage.go index 07e39826ed..caea53f924 100644 --- a/cli/command/formatter/disk_usage.go +++ b/cli/command/formatter/disk_usage.go @@ -234,7 +234,6 @@ func (c *diskUsageImagesContext) Reclaimable() string { type diskUsageContainersContext struct { HeaderContext - verbose bool containers []*types.Container } @@ -297,7 +296,6 @@ func (c *diskUsageContainersContext) Reclaimable() string { type diskUsageVolumesContext struct { HeaderContext - verbose bool volumes []*types.Volume } diff --git a/cli/command/formatter/reflect_test.go b/cli/command/formatter/reflect_test.go index e547b18411..ffda51b858 100644 --- a/cli/command/formatter/reflect_test.go +++ b/cli/command/formatter/reflect_test.go @@ -12,7 +12,7 @@ func (d *dummy) Func1() string { return "Func1" } -func (d *dummy) func2() string { +func (d *dummy) func2() string { // nolint: unused return "func2(should not be marshalled)" } diff --git a/cli/command/image/pull_test.go b/cli/command/image/pull_test.go index b4b57e2abc..d72531b768 100644 --- a/cli/command/image/pull_test.go +++ b/cli/command/image/pull_test.go @@ -6,24 +6,17 @@ import ( "io/ioutil" "testing" - "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/internal/test" - "github.com/docker/distribution/reference" - "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/testutil" "github.com/docker/docker/pkg/testutil/golden" - "github.com/docker/docker/registry" "github.com/stretchr/testify/assert" - "golang.org/x/net/context" ) func TestNewPullCommandErrors(t *testing.T) { testCases := []struct { - name string - args []string - expectedError string - trustedPullFunc func(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, ref reference.Named, - authConfig types.AuthConfig, requestPrivilege types.RequestPrivilegeFunc) error + name string + args []string + expectedError string }{ { name: "wrong-args", @@ -57,10 +50,8 @@ func TestNewPullCommandErrors(t *testing.T) { func TestNewPullCommandSuccess(t *testing.T) { testCases := []struct { - name string - args []string - trustedPullFunc func(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, ref reference.Named, - authConfig types.AuthConfig, requestPrivilege types.RequestPrivilegeFunc) error + name string + args []string }{ { name: "simple", diff --git a/cli/command/image/push_test.go b/cli/command/image/push_test.go index b382ad7ee1..559b1b89c3 100644 --- a/cli/command/image/push_test.go +++ b/cli/command/image/push_test.go @@ -7,15 +7,11 @@ import ( "strings" "testing" - "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/internal/test" - "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/pkg/testutil" - "github.com/docker/docker/registry" "github.com/pkg/errors" "github.com/stretchr/testify/assert" - "golang.org/x/net/context" ) func TestNewPushCommandErrors(t *testing.T) { @@ -60,11 +56,8 @@ func TestNewPushCommandErrors(t *testing.T) { func TestNewPushCommandSuccess(t *testing.T) { testCases := []struct { - name string - args []string - trustedPushFunc func(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, - ref reference.Named, authConfig types.AuthConfig, - requestPrivilege types.RequestPrivilegeFunc) error + name string + args []string }{ { name: "simple", diff --git a/cli/command/node/opts.go b/cli/command/node/opts.go index 484ab5edaf..e30e5de910 100644 --- a/cli/command/node/opts.go +++ b/cli/command/node/opts.go @@ -11,7 +11,6 @@ type nodeOptions struct { } type annotations struct { - name string labels opts.ListOpts } diff --git a/cli/command/registry/login.go b/cli/command/registry/login.go index af79e967cc..ba1b133054 100644 --- a/cli/command/registry/login.go +++ b/cli/command/registry/login.go @@ -16,7 +16,6 @@ type loginOptions struct { serverAddress string user string password string - email string } // NewLoginCommand creates a new `docker login` command diff --git a/cli/command/swarm/unlock_test.go b/cli/command/swarm/unlock_test.go index 991365f873..3dae5239f5 100644 --- a/cli/command/swarm/unlock_test.go +++ b/cli/command/swarm/unlock_test.go @@ -19,7 +19,6 @@ func TestSwarmUnlockErrors(t *testing.T) { testCases := []struct { name string args []string - input string swarmUnlockFunc func(req swarm.UnlockRequest) error infoFunc func() (types.Info, error) expectedError string diff --git a/cli/compose/loader/loader_test.go b/cli/compose/loader/loader_test.go index 4e604431d3..43a02204b7 100644 --- a/cli/compose/loader/loader_test.go +++ b/cli/compose/loader/loader_test.go @@ -632,10 +632,6 @@ func durationPtr(value time.Duration) *time.Duration { return &value } -func int64Ptr(value int64) *int64 { - return &value -} - func uint64Ptr(value uint64) *uint64 { return &value } diff --git a/dockerfiles/Dockerfile.lint b/dockerfiles/Dockerfile.lint index 14c124642e..71ea437914 100644 --- a/dockerfiles/Dockerfile.lint +++ b/dockerfiles/Dockerfile.lint @@ -7,5 +7,6 @@ RUN go get -u gopkg.in/alecthomas/gometalinter.v1 && \ gometalinter --install WORKDIR /go/src/github.com/docker/cli +ENV CGO_ENABLED=0 ENTRYPOINT ["/usr/local/bin/gometalinter"] -CMD ["--config=gometalinter.json", "./..."] +CMD ["--config=gometalinter.json", "./..."] diff --git a/gometalinter.json b/gometalinter.json index f7c6a88a5d..27b6735195 100644 --- a/gometalinter.json +++ b/gometalinter.json @@ -1,6 +1,6 @@ { "Vendor": true, - "Deadline": "2m", + "Deadline": "3m", "Sort": ["linter", "severity", "path"], "Exclude": ["cli/compose/schema/bindata.go"], @@ -14,6 +14,7 @@ "ineffassign", "interfacer", "lll", + "unused", "vet" ],