From 3bf0317fead60e2b8526b47abb2dd243ab57c74d Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 9 Jun 2017 16:41:53 -0400 Subject: [PATCH] Add unconvert linter Signed-off-by: Daniel Nephin --- cli/command/formatter/container.go | 4 ++-- cli/command/formatter/history.go | 9 +++------ cli/command/formatter/image.go | 4 ++-- cli/command/swarm/opts.go | 4 ++-- cli/command/system/info.go | 3 +-- cli/trust/trust.go | 2 +- gometalinter.json | 1 + opts/opts.go | 2 +- opts/quotedstring.go | 2 +- opts/throttledevice.go | 5 +---- 10 files changed, 15 insertions(+), 21 deletions(-) diff --git a/cli/command/formatter/container.go b/cli/command/formatter/container.go index 9b5c24636c..8ffb1a69b2 100644 --- a/cli/command/formatter/container.go +++ b/cli/command/formatter/container.go @@ -171,11 +171,11 @@ func (c *containerContext) Command() string { } func (c *containerContext) CreatedAt() string { - return time.Unix(int64(c.c.Created), 0).String() + return time.Unix(c.c.Created, 0).String() } func (c *containerContext) RunningFor() string { - createdAt := time.Unix(int64(c.c.Created), 0) + createdAt := time.Unix(c.c.Created, 0) return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago" } diff --git a/cli/command/formatter/history.go b/cli/command/formatter/history.go index ed2af4637e..161aaa4b00 100644 --- a/cli/command/formatter/history.go +++ b/cli/command/formatter/history.go @@ -79,21 +79,18 @@ func (c *historyContext) ID() string { } func (c *historyContext) CreatedAt() string { - var created string - created = units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(c.h.Created), 0))) - return created + return units.HumanDuration(time.Now().UTC().Sub(time.Unix(c.h.Created, 0))) } func (c *historyContext) CreatedSince() string { - var created string - created = units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(c.h.Created), 0))) + created := units.HumanDuration(time.Now().UTC().Sub(time.Unix(c.h.Created, 0))) return created + " ago" } func (c *historyContext) CreatedBy() string { createdBy := strings.Replace(c.h.CreatedBy, "\t", " ", -1) if c.trunc { - createdBy = stringutils.Ellipsis(createdBy, 45) + return stringutils.Ellipsis(createdBy, 45) } return createdBy } diff --git a/cli/command/formatter/image.go b/cli/command/formatter/image.go index 3aae34ea11..cbd3edad3c 100644 --- a/cli/command/formatter/image.go +++ b/cli/command/formatter/image.go @@ -234,12 +234,12 @@ func (c *imageContext) Digest() string { } func (c *imageContext) CreatedSince() string { - createdAt := time.Unix(int64(c.i.Created), 0) + createdAt := time.Unix(c.i.Created, 0) return units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago" } func (c *imageContext) CreatedAt() string { - return time.Unix(int64(c.i.Created), 0).String() + return time.Unix(c.i.Created, 0).String() } func (c *imageContext) Size() string { diff --git a/cli/command/swarm/opts.go b/cli/command/swarm/opts.go index 4625835055..0522f9fdfa 100644 --- a/cli/command/swarm/opts.go +++ b/cli/command/swarm/opts.go @@ -217,13 +217,13 @@ func parseExternalCA(caSpec string) (*swarm.ExternalCA, error) { } func addSwarmCAFlags(flags *pflag.FlagSet, opts *swarmOptions) { - flags.DurationVar(&opts.nodeCertExpiry, flagCertExpiry, time.Duration(90*24*time.Hour), "Validity period for node certificates (ns|us|ms|s|m|h)") + flags.DurationVar(&opts.nodeCertExpiry, flagCertExpiry, 90*24*time.Hour, "Validity period for node certificates (ns|us|ms|s|m|h)") flags.Var(&opts.externalCA, flagExternalCA, "Specifications of one or more certificate signing endpoints") } func addSwarmFlags(flags *pflag.FlagSet, opts *swarmOptions) { flags.Int64Var(&opts.taskHistoryLimit, flagTaskHistoryLimit, 5, "Task history retention limit") - flags.DurationVar(&opts.dispatcherHeartbeat, flagDispatcherHeartbeat, time.Duration(5*time.Second), "Dispatcher heartbeat period (ns|us|ms|s|m|h)") + flags.DurationVar(&opts.dispatcherHeartbeat, flagDispatcherHeartbeat, 5*time.Second, "Dispatcher heartbeat period (ns|us|ms|s|m|h)") flags.Uint64Var(&opts.maxSnapshots, flagMaxSnapshots, 0, "Number of additional Raft snapshots to retain") flags.SetAnnotation(flagMaxSnapshots, "version", []string{"1.25"}) flags.Uint64Var(&opts.snapshotInterval, flagSnapshotInterval, 10000, "Number of log entries between Raft snapshots") diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 7b91066974..55b867b296 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -5,7 +5,6 @@ import ( "io" "sort" "strings" - "time" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" @@ -120,7 +119,7 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error { fmt.Fprintf(dockerCli.Out(), " Heartbeat Tick: %d\n", info.Swarm.Cluster.Spec.Raft.HeartbeatTick) fmt.Fprintf(dockerCli.Out(), " Election Tick: %d\n", info.Swarm.Cluster.Spec.Raft.ElectionTick) fmt.Fprintf(dockerCli.Out(), " Dispatcher:\n") - fmt.Fprintf(dockerCli.Out(), " Heartbeat Period: %s\n", units.HumanDuration(time.Duration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod))) + fmt.Fprintf(dockerCli.Out(), " Heartbeat Period: %s\n", units.HumanDuration(info.Swarm.Cluster.Spec.Dispatcher.HeartbeatPeriod)) fmt.Fprintf(dockerCli.Out(), " CA Configuration:\n") fmt.Fprintf(dockerCli.Out(), " Expiry Duration: %s\n", units.HumanDuration(info.Swarm.Cluster.Spec.CAConfig.NodeCertExpiry)) fmt.Fprintf(dockerCli.Out(), " Force Rotate: %d\n", info.Swarm.Cluster.Spec.CAConfig.ForceRotate) diff --git a/cli/trust/trust.go b/cli/trust/trust.go index c325b966a8..600a2acc41 100644 --- a/cli/trust/trust.go +++ b/cli/trust/trust.go @@ -161,7 +161,7 @@ func GetNotaryRepository(streams command.Streams, repoInfo *registry.RepositoryI } tokenHandler := auth.NewTokenHandlerWithOptions(tokenHandlerOptions) basicHandler := auth.NewBasicHandler(creds) - modifiers = append(modifiers, transport.RequestModifier(auth.NewAuthorizer(challengeManager, tokenHandler, basicHandler))) + modifiers = append(modifiers, auth.NewAuthorizer(challengeManager, tokenHandler, basicHandler)) tr := transport.NewTransport(base, modifiers...) return client.NewNotaryRepository( diff --git a/gometalinter.json b/gometalinter.json index eb86268e63..9ba9ea47a5 100644 --- a/gometalinter.json +++ b/gometalinter.json @@ -15,6 +15,7 @@ "interfacer", "lll", "misspell", + "unconvert", "unused", "vet" ], diff --git a/opts/opts.go b/opts/opts.go index f76f308051..d915ec2f76 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -179,7 +179,7 @@ func (opts *MapOpts) GetAll() map[string]string { } func (opts *MapOpts) String() string { - return fmt.Sprintf("%v", map[string]string((opts.values))) + return fmt.Sprintf("%v", opts.values) } // Type returns a string name for this Option type diff --git a/opts/quotedstring.go b/opts/quotedstring.go index fb1e5374bc..09c68a5261 100644 --- a/opts/quotedstring.go +++ b/opts/quotedstring.go @@ -18,7 +18,7 @@ func (s *QuotedString) Type() string { } func (s *QuotedString) String() string { - return string(*s.value) + return *s.value } func trimQuotes(value string) string { diff --git a/opts/throttledevice.go b/opts/throttledevice.go index 65dd3ebf68..0959efae35 100644 --- a/opts/throttledevice.go +++ b/opts/throttledevice.go @@ -52,10 +52,7 @@ func ValidateThrottleIOpsDevice(val string) (*blkiodev.ThrottleDevice, error) { return nil, fmt.Errorf("invalid rate for device: %s. The correct format is :. Number must be a positive integer", val) } - return &blkiodev.ThrottleDevice{ - Path: split[0], - Rate: uint64(rate), - }, nil + return &blkiodev.ThrottleDevice{Path: split[0], Rate: rate}, nil } // ThrottledeviceOpt defines a map of ThrottleDevices