From 3724fb7f37c81e050ca9d66c79c6026b928af884 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 9 Jun 2017 17:42:16 -0400 Subject: [PATCH] Add gosimple lint Signed-off-by: Daniel Nephin --- cli/command/container/exec.go | 7 +------ cli/command/container/opts.go | 2 +- cli/command/formatter/disk_usage.go | 2 +- cli/command/service/logs.go | 2 +- cli/command/service/opts.go | 2 +- cli/command/stack/deploy_composefile.go | 5 +---- cli/command/stack/list.go | 2 +- cli/command/system/info.go | 2 +- cli/compose/convert/service.go | 7 ++----- cli/config/credentials/native_store.go | 2 +- cli/internal/test/store.go | 3 +-- gometalinter.json | 3 ++- opts/weightdevice.go | 7 +------ 13 files changed, 15 insertions(+), 31 deletions(-) diff --git a/cli/command/container/exec.go b/cli/command/container/exec.go index 843b609a0e..bbcd34ae0c 100644 --- a/cli/command/container/exec.go +++ b/cli/command/container/exec.go @@ -111,12 +111,7 @@ func runExec(dockerCli command.Cli, options *execOptions, container string, exec Tty: execConfig.Tty, } - if err := client.ContainerExecStart(ctx, execID, execStartCheck); err != nil { - return err - } - // For now don't print this - wait for when we support exec wait() - // fmt.Fprintf(dockerCli.Out(), "%s\n", execID) - return nil + return client.ContainerExecStart(ctx, execID, execStartCheck) } // Interactive exec requested. diff --git a/cli/command/container/opts.go b/cli/command/container/opts.go index 2b7471b352..82d7426c75 100644 --- a/cli/command/container/opts.go +++ b/cli/command/container/opts.go @@ -23,7 +23,7 @@ import ( ) var ( - deviceCgroupRuleRegexp = regexp.MustCompile("^[acb] ([0-9]+|\\*):([0-9]+|\\*) [rwm]{1,3}$") + deviceCgroupRuleRegexp = regexp.MustCompile(`^[acb] ([0-9]+|\*):([0-9]+|\*) [rwm]{1,3}$`) ) // containerOptions is a data object with all the options for creating a container diff --git a/cli/command/formatter/disk_usage.go b/cli/command/formatter/disk_usage.go index caea53f924..9a3b4b9fe6 100644 --- a/cli/command/formatter/disk_usage.go +++ b/cli/command/formatter/disk_usage.go @@ -65,7 +65,7 @@ reclaimable: {{.Reclaimable}} } func (ctx *DiskUsageContext) Write() (err error) { - if ctx.Verbose == false { + if !ctx.Verbose { ctx.buffer = bytes.NewBufferString("") ctx.preFormat() diff --git a/cli/command/service/logs.go b/cli/command/service/logs.go index fbefa5f52e..3d3b3f1d46 100644 --- a/cli/command/service/logs.go +++ b/cli/command/service/logs.go @@ -164,7 +164,7 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error { // getMaxLength gets the maximum length of the number in base 10 func getMaxLength(i int) int { - return len(strconv.FormatInt(int64(i), 10)) + return len(strconv.Itoa(i)) } type taskFormatter struct { diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index 5e70863f01..5d1595b055 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -354,7 +354,7 @@ func convertNetworks(ctx context.Context, apiClient client.NetworkAPIClient, net if err != nil { return nil, err } - netAttach = append(netAttach, swarm.NetworkAttachmentConfig{Target: net.Target, Aliases: net.Aliases, DriverOpts: net.DriverOpts}) + netAttach = append(netAttach, swarm.NetworkAttachmentConfig(net)) } sort.Sort(byNetworkTarget(netAttach)) return netAttach, nil diff --git a/cli/command/stack/deploy_composefile.go b/cli/command/stack/deploy_composefile.go index e8cab8fa4e..8e5dfed4d5 100644 --- a/cli/command/stack/deploy_composefile.go +++ b/cli/command/stack/deploy_composefile.go @@ -134,10 +134,7 @@ func getConfigDetails(composefile string) (composetypes.ConfigDetails, error) { // TODO: support multiple files details.ConfigFiles = []composetypes.ConfigFile{*configFile} details.Environment, err = buildEnvironment(os.Environ()) - if err != nil { - return details, err - } - return details, nil + return details, err } func buildEnvironment(env []string) (map[string]string, error) { diff --git a/cli/command/stack/list.go b/cli/command/stack/list.go index 4560a98ec9..26566f6cb2 100644 --- a/cli/command/stack/list.go +++ b/cli/command/stack/list.go @@ -69,7 +69,7 @@ func getStacks(ctx context.Context, apiclient client.APIClient) ([]*formatter.St if err != nil { return nil, err } - m := make(map[string]*formatter.Stack, 0) + m := make(map[string]*formatter.Stack) for _, service := range services { labels := service.Spec.Labels name, ok := labels[convert.LabelNamespace] diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 55b867b296..f2a404e905 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -263,7 +263,7 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error { if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) { fmt.Fprintln(dockerCli.Out(), "Insecure Registries:") for _, registry := range info.RegistryConfig.IndexConfigs { - if registry.Secure == false { + if !registry.Secure { fmt.Fprintf(dockerCli.Out(), " %s\n", registry.Name) } } diff --git a/cli/compose/convert/service.go b/cli/compose/convert/service.go index 75c86e9e64..730f5e1ee5 100644 --- a/cli/compose/convert/service.go +++ b/cli/compose/convert/service.go @@ -563,9 +563,6 @@ func convertCredentialSpec(spec composetypes.CredentialSpecConfig) (*swarm.Crede if spec.File != "" && spec.Registry != "" { return nil, errors.New("Invalid credential spec - must provide one of `File` or `Registry`") } - - return &swarm.CredentialSpec{ - File: spec.File, - Registry: spec.Registry, - }, nil + swarmCredSpec := swarm.CredentialSpec(spec) + return &swarmCredSpec, nil } diff --git a/cli/config/credentials/native_store.go b/cli/config/credentials/native_store.go index 15bb0e912f..cef34db92f 100644 --- a/cli/config/credentials/native_store.go +++ b/cli/config/credentials/native_store.go @@ -73,7 +73,7 @@ func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) { if err != nil { return nil, err } - ac, _ := fileConfigs[registry] // might contain Email + ac := fileConfigs[registry] // might contain Email ac.Username = creds.Username ac.Password = creds.Password ac.IdentityToken = creds.IdentityToken diff --git a/cli/internal/test/store.go b/cli/internal/test/store.go index 28e52bab05..e5b3de7abb 100644 --- a/cli/internal/test/store.go +++ b/cli/internal/test/store.go @@ -53,8 +53,7 @@ func (c *fakeStore) Get(serverAddress string) (types.AuthConfig, error) { if c.getFunc != nil { return c.getFunc(serverAddress) } - authConfig, _ := c.store[serverAddress] - return authConfig, nil + return c.store[serverAddress], nil } func (c *fakeStore) GetAll() (map[string]types.AuthConfig, error) { diff --git a/gometalinter.json b/gometalinter.json index 873f9a2bd8..4791bb01fa 100644 --- a/gometalinter.json +++ b/gometalinter.json @@ -1,6 +1,6 @@ { "Vendor": true, - "Deadline": "5m", + "Deadline": "8m", "Sort": ["linter", "severity", "path"], "Exclude": ["cli/compose/schema/bindata.go"], @@ -11,6 +11,7 @@ "gofmt", "goimports", "golint", + "gosimple", "ineffassign", "interfacer", "lll", diff --git a/opts/weightdevice.go b/opts/weightdevice.go index 7e3d064f27..46ce9b6567 100644 --- a/opts/weightdevice.go +++ b/opts/weightdevice.go @@ -75,12 +75,7 @@ func (opt *WeightdeviceOpt) String() string { // GetList returns a slice of pointers to WeightDevices. func (opt *WeightdeviceOpt) GetList() []*blkiodev.WeightDevice { - var weightdevice []*blkiodev.WeightDevice - for _, v := range opt.values { - weightdevice = append(weightdevice, v) - } - - return weightdevice + return opt.values } // Type returns the option type