Skip to content

Commit 3826f5a

Browse files
authored
Merge pull request docker#5370 from thaJeztah/fix_linting_issues
Fix linting issues in preparation of Go and GolangCI-lint update
2 parents 436080b + c4a55df commit 3826f5a

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

cli/command/manifest/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func NewManifestCommand(dockerCli command.Cli) *cobra.Command {
1818
Long: manifestDescription,
1919
Args: cli.NoArgs,
2020
Run: func(cmd *cobra.Command, args []string) {
21-
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString())
21+
_, _ = fmt.Fprint(dockerCli.Err(), "\n"+cmd.UsageString())
2222
},
2323
Annotations: map[string]string{"experimentalCLI": ""},
2424
}

cli/command/service/remove.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ func runRemove(ctx context.Context, dockerCli command.Cli, sids []string) error
3939
errs = append(errs, err.Error())
4040
continue
4141
}
42-
fmt.Fprintf(dockerCli.Out(), "%s\n", sid)
42+
_, _ = fmt.Fprintf(dockerCli.Out(), "%s\n", sid)
4343
}
4444
if len(errs) > 0 {
45-
return errors.Errorf(strings.Join(errs, "\n"))
45+
return errors.New(strings.Join(errs, "\n"))
4646
}
4747
return nil
4848
}

cli/command/service/scale.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func runScale(ctx context.Context, dockerCli command.Cli, options *scaleOptions,
9090
if len(errs) == 0 {
9191
return nil
9292
}
93-
return errors.Errorf(strings.Join(errs, "\n"))
93+
return errors.New(strings.Join(errs, "\n"))
9494
}
9595

9696
func runServiceScale(ctx context.Context, dockerCli command.Cli, serviceID string, scale uint64) error {

cli/command/stack/swarm/remove.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func RunRemove(ctx context.Context, dockerCli command.Cli, opts options.Remove)
4848
}
4949

5050
if len(services)+len(networks)+len(secrets)+len(configs) == 0 {
51-
fmt.Fprintf(dockerCli.Err(), "Nothing found in stack: %s\n", namespace)
51+
_, _ = fmt.Fprintf(dockerCli.Err(), "Nothing found in stack: %s\n", namespace)
5252
continue
5353
}
5454

@@ -71,7 +71,7 @@ func RunRemove(ctx context.Context, dockerCli command.Cli, opts options.Remove)
7171
}
7272

7373
if len(errs) > 0 {
74-
return errors.Errorf(strings.Join(errs, "\n"))
74+
return errors.New(strings.Join(errs, "\n"))
7575
}
7676
return nil
7777
}

cli/command/system/info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func prettyPrintServerInfo(streams command.Streams, info *dockerInfo) []error {
372372
fprintln(output, " Product License:", info.ProductLicense)
373373
}
374374

375-
if info.DefaultAddressPools != nil && len(info.DefaultAddressPools) > 0 {
375+
if len(info.DefaultAddressPools) > 0 {
376376
fprintln(output, " Default Address Pools:")
377377
for _, pool := range info.DefaultAddressPools {
378378
fprintf(output, " Base: %s, Size: %d\n", pool.Base, pool.Size)

cli/command/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func ValidateOutputPath(path string) error {
222222
}
223223

224224
if err := ValidateOutputPathFileMode(fileInfo.Mode()); err != nil {
225-
return errors.Wrapf(err, fmt.Sprintf("invalid output path: %q must be a directory or a regular file", path))
225+
return errors.Wrapf(err, "invalid output path: %q must be a directory or a regular file", path)
226226
}
227227
}
228228
return nil

cli/required.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,52 @@ func NoArgs(cmd *cobra.Command, args []string) error {
3030
}
3131

3232
// RequiresMinArgs returns an error if there is not at least min args
33-
func RequiresMinArgs(min int) cobra.PositionalArgs {
33+
func RequiresMinArgs(minArgs int) cobra.PositionalArgs {
3434
return func(cmd *cobra.Command, args []string) error {
35-
if len(args) >= min {
35+
if len(args) >= minArgs {
3636
return nil
3737
}
3838
return errors.Errorf(
3939
"%[1]s: '%[2]s' requires at least %[3]d %[4]s\n\nUsage: %[5]s\n\nSee '%[2]s --help' for more information",
4040
binName(cmd),
4141
cmd.CommandPath(),
42-
min,
43-
pluralize("argument", min),
42+
minArgs,
43+
pluralize("argument", minArgs),
4444
cmd.UseLine(),
4545
)
4646
}
4747
}
4848

4949
// RequiresMaxArgs returns an error if there is not at most max args
50-
func RequiresMaxArgs(max int) cobra.PositionalArgs {
50+
func RequiresMaxArgs(maxArgs int) cobra.PositionalArgs {
5151
return func(cmd *cobra.Command, args []string) error {
52-
if len(args) <= max {
52+
if len(args) <= maxArgs {
5353
return nil
5454
}
5555
return errors.Errorf(
5656
"%[1]s: '%[2]s' requires at most %[3]d %[4]s\n\nUsage: %[5]s\n\nSRun '%[2]s --help' for more information",
5757
binName(cmd),
5858
cmd.CommandPath(),
59-
max,
60-
pluralize("argument", max),
59+
maxArgs,
60+
pluralize("argument", maxArgs),
6161
cmd.UseLine(),
6262
)
6363
}
6464
}
6565

6666
// RequiresRangeArgs returns an error if there is not at least min args and at most max args
67-
func RequiresRangeArgs(min int, max int) cobra.PositionalArgs {
67+
func RequiresRangeArgs(minArgs int, maxArgs int) cobra.PositionalArgs {
6868
return func(cmd *cobra.Command, args []string) error {
69-
if len(args) >= min && len(args) <= max {
69+
if len(args) >= minArgs && len(args) <= maxArgs {
7070
return nil
7171
}
7272
return errors.Errorf(
7373
"%[1]s: '%[2]s' requires at least %[3]d and at most %[4]d %[5]s\n\nUsage: %[6]s\n\nRun '%[2]s --help' for more information",
7474
binName(cmd),
7575
cmd.CommandPath(),
76-
min,
77-
max,
78-
pluralize("argument", max),
76+
minArgs,
77+
maxArgs,
78+
pluralize("argument", maxArgs),
7979
cmd.UseLine(),
8080
)
8181
}

e2e/global/cli_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func TestPromptExitCode(t *testing.T) {
214214
default:
215215

216216
if err := bufioWriter.Flush(); err != nil {
217-
return poll.Continue(err.Error())
217+
return poll.Continue("%v", err)
218218
}
219219
if strings.Contains(buf.String(), "[y/N]") {
220220
return poll.Success()

0 commit comments

Comments
 (0)