Skip to content

Commit 5d17c29

Browse files
authored
Merge pull request #5372 from thaJeztah/27.x_backport_fix_linting_issues
[27.x backport] Fix linting issues in preparation of Go and GolangCI-lint update
2 parents f042ddb + 64b9e4c commit 5d17c29

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
@@ -27,16 +27,16 @@ func NoArgs(cmd *cobra.Command, args []string) error {
2727
}
2828

2929
// RequiresMinArgs returns an error if there is not at least min args
30-
func RequiresMinArgs(min int) cobra.PositionalArgs {
30+
func RequiresMinArgs(minArgs int) cobra.PositionalArgs {
3131
return func(cmd *cobra.Command, args []string) error {
32-
if len(args) >= min {
32+
if len(args) >= minArgs {
3333
return nil
3434
}
3535
return errors.Errorf(
3636
"%q requires at least %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s",
3737
cmd.CommandPath(),
38-
min,
39-
pluralize("argument", min),
38+
minArgs,
39+
pluralize("argument", minArgs),
4040
cmd.CommandPath(),
4141
cmd.UseLine(),
4242
cmd.Short,
@@ -45,16 +45,16 @@ func RequiresMinArgs(min int) cobra.PositionalArgs {
4545
}
4646

4747
// RequiresMaxArgs returns an error if there is not at most max args
48-
func RequiresMaxArgs(max int) cobra.PositionalArgs {
48+
func RequiresMaxArgs(maxArgs int) cobra.PositionalArgs {
4949
return func(cmd *cobra.Command, args []string) error {
50-
if len(args) <= max {
50+
if len(args) <= maxArgs {
5151
return nil
5252
}
5353
return errors.Errorf(
5454
"%q requires at most %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s",
5555
cmd.CommandPath(),
56-
max,
57-
pluralize("argument", max),
56+
maxArgs,
57+
pluralize("argument", maxArgs),
5858
cmd.CommandPath(),
5959
cmd.UseLine(),
6060
cmd.Short,
@@ -63,17 +63,17 @@ func RequiresMaxArgs(max int) cobra.PositionalArgs {
6363
}
6464

6565
// RequiresRangeArgs returns an error if there is not at least min args and at most max args
66-
func RequiresRangeArgs(min int, max int) cobra.PositionalArgs {
66+
func RequiresRangeArgs(minArgs int, maxArgs int) cobra.PositionalArgs {
6767
return func(cmd *cobra.Command, args []string) error {
68-
if len(args) >= min && len(args) <= max {
68+
if len(args) >= minArgs && len(args) <= maxArgs {
6969
return nil
7070
}
7171
return errors.Errorf(
7272
"%q requires at least %d and at most %d %s.\nSee '%s --help'.\n\nUsage: %s\n\n%s",
7373
cmd.CommandPath(),
74-
min,
75-
max,
76-
pluralize("argument", max),
74+
minArgs,
75+
maxArgs,
76+
pluralize("argument", maxArgs),
7777
cmd.CommandPath(),
7878
cmd.UseLine(),
7979
cmd.Short,

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)