fix increment-decrement from revive

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-05-15 15:44:07 +02:00
parent 381d9d0723
commit 90ab64cbda
7 changed files with 8 additions and 7 deletions

View File

@@ -207,6 +207,7 @@ linters:
# Only listed rules are applied
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md
rules:
- name: increment-decrement
# FIXME make sure all packages have a description. Currently, there's many packages without.
- name: package-comments
disabled: true

View File

@@ -108,7 +108,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu
// Images considered for pruning.
imagesToPrune := map[string]c8dimages.Image{}
for _, img := range allImages {
digestRefCount[img.Target.Digest] += 1
digestRefCount[img.Target.Digest]++
if !danglingOnly || isDanglingImage(img) {
canBePruned := filterFunc(img)
@@ -138,7 +138,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu
dgst := img.Target.Digest
if digestRefCount[dgst] > 1 {
digestRefCount[dgst] -= 1
digestRefCount[dgst]--
continue
}

View File

@@ -1751,7 +1751,7 @@ func TestAdvertiseAddresses(t *testing.T) {
if pa != matchIP || slices.Compare(ha, ctr2NewHwAddr) != 0 {
continue
}
count += 1
count++
var interval time.Duration
if !lastTimestamp.IsZero() {
interval = p.ReceivedAt.Sub(lastTimestamp)

View File

@@ -57,7 +57,7 @@ func (nlh Handle) Close() {
}
func retryOnIntr(f func() error) {
for attempt := 0; attempt < maxAttempts; attempt += 1 {
for attempt := 0; attempt < maxAttempts; attempt++ {
if err := f(); !errors.Is(err, netlink.ErrDumpInterrupted) {
return
}

View File

@@ -146,7 +146,7 @@ func (d *driver) parentHasSingleUser(n *network) bool {
networkList := d.getNetworks()
for _, testN := range networkList {
if n.config.Parent == testN.config.Parent {
users += 1
users++
}
}
return users == 1

View File

@@ -181,7 +181,7 @@ func (rc *ResolvConf) Options() []string {
// Option("ndots") -> ("1", true)
// Option("edns0") -> ("", true)
func (rc *ResolvConf) Option(search string) (string, bool) {
for i := len(rc.options) - 1; i >= 0; i -= 1 {
for i := len(rc.options) - 1; i >= 0; i-- {
k, v, _ := strings.Cut(rc.options[i], ":")
if k == search {
return v, true

View File

@@ -338,7 +338,7 @@ func TestRequestPortForMultipleIPs(t *testing.T) {
assert.Check(t, is.Equal(port, 10000))
// Multi-port range.
for i := 20000; i < 20004; i += 1 {
for i := 20000; i < 20004; i++ {
port, err = p.RequestPortsInRange(addrs, "tcp", 20000, 20004)
assert.Check(t, err)
assert.Check(t, is.Equal(port, i))