From ce1a39ab34c8bb04b81a887cf7c070ae240eb23e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 12 Nov 2024 13:08:20 +0100 Subject: [PATCH] client: remove redundant capturing of loop vars (copyloopvar) client/client_test.go:91:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ client/client_test.go:326:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ client/client_test.go:481:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ client/image_list_test.go:183:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ client/image_push_test.go:163:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ client/image_tag_test.go:50:3: The copy of the 'for' variable "repo" can be deleted (Go 1.22+) (copyloopvar) repo := repo ^ client/image_tag_test.go:61:3: The copy of the 'for' variable "repotag" can be deleted (Go 1.22+) (copyloopvar) repotag := repotag ^ client/ping_test.go:114:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ client/request_test.go:53:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar) tc := tc ^ Signed-off-by: Sebastiaan van Stijn --- client/client_test.go | 3 --- client/image_list_test.go | 1 - client/image_push_test.go | 1 - client/image_tag_test.go | 2 -- client/ping_test.go | 1 - client/request_test.go | 1 - 6 files changed, 9 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index 8e5411ebf9..27a0a41c28 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -88,7 +88,6 @@ func TestNewClientWithOpsFromEnv(t *testing.T) { env.PatchAll(t, nil) for _, tc := range testcases { - tc := tc t.Run(tc.doc, func(t *testing.T) { env.PatchAll(t, tc.envs) client, err := NewClientWithOpts(FromEnv) @@ -323,7 +322,6 @@ func TestNegotiateAPIVersion(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.doc, func(t *testing.T) { opts := make([]Opt, 0) if tc.clientVersion != "" { @@ -478,7 +476,6 @@ func TestClientRedirect(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.httpMethod, func(t *testing.T) { req, err := http.NewRequest(tc.httpMethod, "/redirectme", nil) assert.Check(t, err) diff --git a/client/image_list_test.go b/client/image_list_test.go index 0b332228e3..8dbfdd9a34 100644 --- a/client/image_list_test.go +++ b/client/image_list_test.go @@ -180,7 +180,6 @@ func TestImageListWithSharedSize(t *testing.T) { {name: "set after 1.42, if requested", version: "1.42", options: image.ListOptions{SharedSize: true}, sharedSize: "1"}, {name: "unset before 1.42, even if requested", version: "1.41", options: image.ListOptions{SharedSize: true}}, } { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() var query url.Values diff --git a/client/image_push_test.go b/client/image_push_test.go index cd49bfb8bd..795ed183d2 100644 --- a/client/image_push_test.go +++ b/client/image_push_test.go @@ -160,7 +160,6 @@ func TestImagePushWithoutErrors(t *testing.T) { }, } for _, tc := range testCases { - tc := tc t.Run(fmt.Sprintf("%s,all-tags=%t", tc.reference, tc.all), func(t *testing.T) { client := &Client{ client: newMockClient(func(req *http.Request) (*http.Response, error) { diff --git a/client/image_tag_test.go b/client/image_tag_test.go index 1e420b9a87..78bf90845d 100644 --- a/client/image_tag_test.go +++ b/client/image_tag_test.go @@ -47,7 +47,6 @@ func TestImageTagInvalidSourceImageName(t *testing.T) { invalidRepos := []string{"fo$z$", "Foo@3cc", "Foo$3", "Foo*3", "Fo^3", "Foo!3", "F)xcz(", "fo%asd", "aa/asdf$$^/aa"} for _, repo := range invalidRepos { - repo := repo t.Run("invalidRepo/"+repo, func(t *testing.T) { t.Parallel() err := client.ImageTag(ctx, "busybox", repo) @@ -58,7 +57,6 @@ func TestImageTagInvalidSourceImageName(t *testing.T) { longTag := testutil.GenerateRandomAlphaOnlyString(121) invalidTags := []string{"repo:fo$z$", "repo:Foo@3cc", "repo:Foo$3", "repo:Foo*3", "repo:Fo^3", "repo:Foo!3", "repo:%goodbye", "repo:#hashtagit", "repo:F)xcz(", "repo:-foo", "repo:..", longTag} for _, repotag := range invalidTags { - repotag := repotag t.Run("invalidTag/"+repotag, func(t *testing.T) { t.Parallel() err := client.ImageTag(ctx, "busybox", repotag) diff --git a/client/ping_test.go b/client/ping_test.go index cbea9545c7..dcbd6b5ae5 100644 --- a/client/ping_test.go +++ b/client/ping_test.go @@ -111,7 +111,6 @@ func TestPingHeadFallback(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(http.StatusText(tc.status), func(t *testing.T) { var reqs []string client := &Client{ diff --git a/client/request_test.go b/client/request_test.go index 127c567b5f..69a1266bce 100644 --- a/client/request_test.go +++ b/client/request_test.go @@ -50,7 +50,6 @@ func TestSetHostHeader(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.host, func(t *testing.T) { hostURL, err := ParseHostURL(tc.host) assert.Check(t, err)