Browse code

fix increment-decrement from revive

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

Matthieu MOREL authored on 2025/05/15 22:44:07
Showing 7 changed files
... ...
@@ -207,6 +207,7 @@ linters:
207 207
       # Only listed rules are applied
208 208
       # https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md
209 209
       rules:
210
+        - name: increment-decrement
210 211
           # FIXME make sure all packages have a description. Currently, there's many packages without.
211 212
         - name: package-comments
212 213
           disabled: true
... ...
@@ -108,7 +108,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu
108 108
 	// Images considered for pruning.
109 109
 	imagesToPrune := map[string]c8dimages.Image{}
110 110
 	for _, img := range allImages {
111
-		digestRefCount[img.Target.Digest] += 1
111
+		digestRefCount[img.Target.Digest]++
112 112
 
113 113
 		if !danglingOnly || isDanglingImage(img) {
114 114
 			canBePruned := filterFunc(img)
... ...
@@ -138,7 +138,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu
138 138
 		dgst := img.Target.Digest
139 139
 
140 140
 		if digestRefCount[dgst] > 1 {
141
-			digestRefCount[dgst] -= 1
141
+			digestRefCount[dgst]--
142 142
 			continue
143 143
 		}
144 144
 
... ...
@@ -1751,7 +1751,7 @@ func TestAdvertiseAddresses(t *testing.T) {
1751 1751
 					if pa != matchIP || slices.Compare(ha, ctr2NewHwAddr) != 0 {
1752 1752
 						continue
1753 1753
 					}
1754
-					count += 1
1754
+					count++
1755 1755
 					var interval time.Duration
1756 1756
 					if !lastTimestamp.IsZero() {
1757 1757
 						interval = p.ReceivedAt.Sub(lastTimestamp)
... ...
@@ -57,7 +57,7 @@ func (nlh Handle) Close() {
57 57
 }
58 58
 
59 59
 func retryOnIntr(f func() error) {
60
-	for attempt := 0; attempt < maxAttempts; attempt += 1 {
60
+	for attempt := 0; attempt < maxAttempts; attempt++ {
61 61
 		if err := f(); !errors.Is(err, netlink.ErrDumpInterrupted) {
62 62
 			return
63 63
 		}
... ...
@@ -146,7 +146,7 @@ func (d *driver) parentHasSingleUser(n *network) bool {
146 146
 	networkList := d.getNetworks()
147 147
 	for _, testN := range networkList {
148 148
 		if n.config.Parent == testN.config.Parent {
149
-			users += 1
149
+			users++
150 150
 		}
151 151
 	}
152 152
 	return users == 1
... ...
@@ -181,7 +181,7 @@ func (rc *ResolvConf) Options() []string {
181 181
 //	Option("ndots") -> ("1", true)
182 182
 //	Option("edns0") -> ("", true)
183 183
 func (rc *ResolvConf) Option(search string) (string, bool) {
184
-	for i := len(rc.options) - 1; i >= 0; i -= 1 {
184
+	for i := len(rc.options) - 1; i >= 0; i-- {
185 185
 		k, v, _ := strings.Cut(rc.options[i], ":")
186 186
 		if k == search {
187 187
 			return v, true
... ...
@@ -338,7 +338,7 @@ func TestRequestPortForMultipleIPs(t *testing.T) {
338 338
 	assert.Check(t, is.Equal(port, 10000))
339 339
 
340 340
 	// Multi-port range.
341
-	for i := 20000; i < 20004; i += 1 {
341
+	for i := 20000; i < 20004; i++ {
342 342
 		port, err = p.RequestPortsInRange(addrs, "tcp", 20000, 20004)
343 343
 		assert.Check(t, err)
344 344
 		assert.Check(t, is.Equal(port, i))