Add gosimple lint

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-06-09 17:42:16 -04:00
parent 3e3934c19f
commit 3724fb7f37
13 changed files with 15 additions and 31 deletions

View File

@ -111,12 +111,7 @@ func runExec(dockerCli command.Cli, options *execOptions, container string, exec
Tty: execConfig.Tty, Tty: execConfig.Tty,
} }
if err := client.ContainerExecStart(ctx, execID, execStartCheck); err != nil { return client.ContainerExecStart(ctx, execID, execStartCheck)
return err
}
// For now don't print this - wait for when we support exec wait()
// fmt.Fprintf(dockerCli.Out(), "%s\n", execID)
return nil
} }
// Interactive exec requested. // Interactive exec requested.

View File

@ -23,7 +23,7 @@ import (
) )
var ( 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 // containerOptions is a data object with all the options for creating a container

View File

@ -65,7 +65,7 @@ reclaimable: {{.Reclaimable}}
} }
func (ctx *DiskUsageContext) Write() (err error) { func (ctx *DiskUsageContext) Write() (err error) {
if ctx.Verbose == false { if !ctx.Verbose {
ctx.buffer = bytes.NewBufferString("") ctx.buffer = bytes.NewBufferString("")
ctx.preFormat() ctx.preFormat()

View File

@ -164,7 +164,7 @@ func runLogs(dockerCli *command.DockerCli, opts *logsOptions) error {
// getMaxLength gets the maximum length of the number in base 10 // getMaxLength gets the maximum length of the number in base 10
func getMaxLength(i int) int { func getMaxLength(i int) int {
return len(strconv.FormatInt(int64(i), 10)) return len(strconv.Itoa(i))
} }
type taskFormatter struct { type taskFormatter struct {

View File

@ -354,7 +354,7 @@ func convertNetworks(ctx context.Context, apiClient client.NetworkAPIClient, net
if err != nil { if err != nil {
return nil, err 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)) sort.Sort(byNetworkTarget(netAttach))
return netAttach, nil return netAttach, nil

View File

@ -134,10 +134,7 @@ func getConfigDetails(composefile string) (composetypes.ConfigDetails, error) {
// TODO: support multiple files // TODO: support multiple files
details.ConfigFiles = []composetypes.ConfigFile{*configFile} details.ConfigFiles = []composetypes.ConfigFile{*configFile}
details.Environment, err = buildEnvironment(os.Environ()) details.Environment, err = buildEnvironment(os.Environ())
if err != nil {
return details, err return details, err
}
return details, nil
} }
func buildEnvironment(env []string) (map[string]string, error) { func buildEnvironment(env []string) (map[string]string, error) {

View File

@ -69,7 +69,7 @@ func getStacks(ctx context.Context, apiclient client.APIClient) ([]*formatter.St
if err != nil { if err != nil {
return nil, err return nil, err
} }
m := make(map[string]*formatter.Stack, 0) m := make(map[string]*formatter.Stack)
for _, service := range services { for _, service := range services {
labels := service.Spec.Labels labels := service.Spec.Labels
name, ok := labels[convert.LabelNamespace] name, ok := labels[convert.LabelNamespace]

View File

@ -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) { if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) {
fmt.Fprintln(dockerCli.Out(), "Insecure Registries:") fmt.Fprintln(dockerCli.Out(), "Insecure Registries:")
for _, registry := range info.RegistryConfig.IndexConfigs { for _, registry := range info.RegistryConfig.IndexConfigs {
if registry.Secure == false { if !registry.Secure {
fmt.Fprintf(dockerCli.Out(), " %s\n", registry.Name) fmt.Fprintf(dockerCli.Out(), " %s\n", registry.Name)
} }
} }

View File

@ -563,9 +563,6 @@ func convertCredentialSpec(spec composetypes.CredentialSpecConfig) (*swarm.Crede
if spec.File != "" && spec.Registry != "" { if spec.File != "" && spec.Registry != "" {
return nil, errors.New("Invalid credential spec - must provide one of `File` or `Registry`") return nil, errors.New("Invalid credential spec - must provide one of `File` or `Registry`")
} }
swarmCredSpec := swarm.CredentialSpec(spec)
return &swarm.CredentialSpec{ return &swarmCredSpec, nil
File: spec.File,
Registry: spec.Registry,
}, nil
} }

View File

@ -73,7 +73,7 @@ func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
ac, _ := fileConfigs[registry] // might contain Email ac := fileConfigs[registry] // might contain Email
ac.Username = creds.Username ac.Username = creds.Username
ac.Password = creds.Password ac.Password = creds.Password
ac.IdentityToken = creds.IdentityToken ac.IdentityToken = creds.IdentityToken

View File

@ -53,8 +53,7 @@ func (c *fakeStore) Get(serverAddress string) (types.AuthConfig, error) {
if c.getFunc != nil { if c.getFunc != nil {
return c.getFunc(serverAddress) return c.getFunc(serverAddress)
} }
authConfig, _ := c.store[serverAddress] return c.store[serverAddress], nil
return authConfig, nil
} }
func (c *fakeStore) GetAll() (map[string]types.AuthConfig, error) { func (c *fakeStore) GetAll() (map[string]types.AuthConfig, error) {

View File

@ -1,6 +1,6 @@
{ {
"Vendor": true, "Vendor": true,
"Deadline": "5m", "Deadline": "8m",
"Sort": ["linter", "severity", "path"], "Sort": ["linter", "severity", "path"],
"Exclude": ["cli/compose/schema/bindata.go"], "Exclude": ["cli/compose/schema/bindata.go"],
@ -11,6 +11,7 @@
"gofmt", "gofmt",
"goimports", "goimports",
"golint", "golint",
"gosimple",
"ineffassign", "ineffassign",
"interfacer", "interfacer",
"lll", "lll",

View File

@ -75,12 +75,7 @@ func (opt *WeightdeviceOpt) String() string {
// GetList returns a slice of pointers to WeightDevices. // GetList returns a slice of pointers to WeightDevices.
func (opt *WeightdeviceOpt) GetList() []*blkiodev.WeightDevice { func (opt *WeightdeviceOpt) GetList() []*blkiodev.WeightDevice {
var weightdevice []*blkiodev.WeightDevice return opt.values
for _, v := range opt.values {
weightdevice = append(weightdevice, v)
}
return weightdevice
} }
// Type returns the option type // Type returns the option type