Skip to content

Commit 591bd17

Browse files
authored
Merge pull request #5137 from thaJeztah/bump_golangci_lint
update golangci-lint to .v1.59.0 and fix linting issues
2 parents cba002e + 43b97e8 commit 591bd17

58 files changed

Lines changed: 142 additions & 160 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ linters:
4444

4545
run:
4646
timeout: 5m
47-
skip-files:
48-
- cli/compose/schema/bindata.go
49-
- .*generated.*
5047

5148
linters-settings:
5249
depguard:
@@ -58,7 +55,8 @@ linters-settings:
5855
gocyclo:
5956
min-complexity: 16
6057
govet:
61-
check-shadowing: true
58+
enable:
59+
- shadow
6260
settings:
6361
shadow:
6462
strict: true
@@ -94,6 +92,10 @@ issues:
9492
exclude:
9593
- parameter .* always receives
9694

95+
exclude-files:
96+
- cli/compose/schema/bindata.go
97+
- .*generated.*
98+
9799
exclude-rules:
98100
# We prefer to use an "exclude-list" so that new "default" exclusions are not
99101
# automatically inherited. We can decide whether or not to follow upstream

cli-plugins/manager/error_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package manager
22

33
import (
44
"encoding/json"
5-
"fmt"
5+
"errors"
66
"testing"
77

88
"gotest.tools/v3/assert"
@@ -13,7 +13,7 @@ func TestPluginError(t *testing.T) {
1313
err := NewPluginError("new error")
1414
assert.Check(t, is.Error(err, "new error"))
1515

16-
inner := fmt.Errorf("testing")
16+
inner := errors.New("testing")
1717
err = wrapAsPluginError(inner, "wrapping")
1818
assert.Check(t, is.Error(err, "wrapping: testing"))
1919
assert.Check(t, is.ErrorIs(err, inner))

cli/command/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func newAPIClientFromEndpoint(ep docker.Endpoint, configFile *configfile.ConfigF
315315

316316
func resolveDockerEndpoint(s store.Reader, contextName string) (docker.Endpoint, error) {
317317
if s == nil {
318-
return docker.Endpoint{}, fmt.Errorf("no context store initialized")
318+
return docker.Endpoint{}, errors.New("no context store initialized")
319319
}
320320
ctxMeta, err := s.GetMetadata(contextName)
321321
if err != nil {

cli/command/cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func TestInitializeFromClientHangs(t *testing.T) {
192192
ts.Start()
193193
defer ts.Close()
194194

195-
opts := &flags.ClientOptions{Hosts: []string{fmt.Sprintf("unix://%s", socket)}}
195+
opts := &flags.ClientOptions{Hosts: []string{"unix://" + socket}}
196196
configFile := &configfile.ConfigFile{}
197197
apiClient, err := NewAPIClientFromFlags(opts, configFile)
198198
assert.NilError(t, err)

cli/command/container/attach.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package container
22

33
import (
44
"context"
5-
"fmt"
65
"io"
76

87
"github.com/docker/cli/cli"
@@ -158,7 +157,7 @@ func getExitStatus(errC <-chan error, resultC <-chan container.WaitResponse) err
158157
select {
159158
case result := <-resultC:
160159
if result.Error != nil {
161-
return fmt.Errorf(result.Error.Message)
160+
return errors.New(result.Error.Message)
162161
}
163162
if result.StatusCode != 0 {
164163
return cli.StatusError{StatusCode: int(result.StatusCode)}

cli/command/container/attach_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package container
22

33
import (
4-
"fmt"
54
"io"
65
"testing"
76

@@ -79,7 +78,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
7978

8079
func TestGetExitStatus(t *testing.T) {
8180
var (
82-
expectedErr = fmt.Errorf("unexpected error")
81+
expectedErr = errors.New("unexpected error")
8382
errC = make(chan error, 1)
8483
resultC = make(chan container.WaitResponse, 1)
8584
)

cli/command/container/create_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package container
33
import (
44
"context"
55
"errors"
6-
"fmt"
76
"io"
87
"os"
98
"runtime"
@@ -231,7 +230,7 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) {
231230
platform *specs.Platform,
232231
containerName string,
233232
) (container.CreateResponse, error) {
234-
return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image")
233+
return container.CreateResponse{}, errors.New("shouldn't try to pull image")
235234
},
236235
}, test.EnableContentTrust)
237236
fakeCLI.SetNotaryClient(tc.notaryFunc)

cli/command/container/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package container
22

33
import (
4-
"fmt"
4+
"errors"
55
"io"
66
"testing"
77

@@ -147,7 +147,7 @@ func TestContainerListErrors(t *testing.T) {
147147
},
148148
{
149149
containerListFunc: func(_ container.ListOptions) ([]types.Container, error) {
150-
return nil, fmt.Errorf("error listing containers")
150+
return nil, errors.New("error listing containers")
151151
},
152152
expectedError: "error listing containers",
153153
},

cli/command/container/opts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,10 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
574574
return nil, errors.Errorf("--health-retries cannot be negative")
575575
}
576576
if copts.healthStartPeriod < 0 {
577-
return nil, fmt.Errorf("--health-start-period cannot be negative")
577+
return nil, errors.New("--health-start-period cannot be negative")
578578
}
579579
if copts.healthStartInterval < 0 {
580-
return nil, fmt.Errorf("--health-start-interval cannot be negative")
580+
return nil, errors.New("--health-start-interval cannot be negative")
581581
}
582582

583583
healthConfig = &container.HealthConfig{

cli/command/container/opts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func TestParseHostname(t *testing.T) {
335335
hostnameWithDomain := "--hostname=hostname.domainname"
336336
hostnameWithDomainTld := "--hostname=hostname.domainname.tld"
337337
for hostname, expectedHostname := range validHostnames {
338-
if config, _, _ := mustParse(t, fmt.Sprintf("--hostname=%s", hostname)); config.Hostname != expectedHostname {
338+
if config, _, _ := mustParse(t, "--hostname="+hostname); config.Hostname != expectedHostname {
339339
t.Fatalf("Expected the config to have 'hostname' as %q, got %q", expectedHostname, config.Hostname)
340340
}
341341
}

0 commit comments

Comments
 (0)