Browse code

fix stringsCompare and stringConcatSimplify from go-critic

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Matthieu MOREL authored on 2025/05/27 15:28:04
Showing 5 changed files
... ...
@@ -146,8 +146,6 @@ linters:
146 146
         - regexpSimplify
147 147
         - singleCaseSwitch
148 148
         - sloppyReassign
149
-        - stringsCompare
150
-        - stringConcatSimplify
151 149
         - stringXbytes
152 150
         - typeAssertChain
153 151
         - typeDefFirst
... ...
@@ -254,7 +254,7 @@ func (c *containerConfig) labels() map[string]string {
254 254
 
255 255
 	// finally, we apply the system labels, which override all labels.
256 256
 	for k, v := range system {
257
-		labels[strings.Join([]string{systemLabelPrefix, k}, ".")] = v
257
+		labels[systemLabelPrefix+"."+k] = v
258 258
 	}
259 259
 
260 260
 	return labels
... ...
@@ -105,7 +105,7 @@ func (s *DockerAPISuite) TestAPIImagesImportBadSrc(c *testing.T) {
105 105
 
106 106
 	ctx := testutil.GetContext(c)
107 107
 	for _, te := range tt {
108
-		res, _, err := request.Post(ctx, strings.Join([]string{"/images/create?fromSrc=", te.fromSrc}, ""), request.JSON)
108
+		res, _, err := request.Post(ctx, "/images/create?fromSrc="+te.fromSrc, request.JSON)
109 109
 		assert.NilError(c, err)
110 110
 		assert.Equal(c, res.StatusCode, te.statusExp)
111 111
 		assert.Equal(c, res.Header.Get("Content-Type"), "application/json")
... ...
@@ -1679,7 +1679,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *testing.T)
1679 1679
 	if err != nil {
1680 1680
 		t.Fatal(err)
1681 1681
 	}
1682
-	if strings.Compare(strings.TrimSpace(oldContainerIP), strings.TrimSpace(newContainerIP)) == 0 {
1682
+	if strings.TrimSpace(oldContainerIP) == strings.TrimSpace(newContainerIP) {
1683 1683
 		t.Fatalf("new container ip should not equal to old running container  ip")
1684 1684
 	}
1685 1685
 
... ...
@@ -193,7 +193,7 @@ func fetchTable(ip string, port int, network, tableName string, clusterPeers, ne
193 193
 		reader := bufio.NewReader(os.Stdin)
194 194
 		text, _ := reader.ReadString('\n')
195 195
 		text = strings.ReplaceAll(text, "\n", "")
196
-		if strings.Compare(text, "Yes") == 0 {
196
+		if text == "Yes" {
197 197
 			for _, k := range orphanKeys {
198 198
 				r, err := http.Get(fmt.Sprintf(deleteEntry, ip, port, network, tableName, k))
199 199
 				if err != nil {