From 7bac03d03759f1260629953d787cbf3a2c01f2a1 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:04:05 +0200 Subject: [PATCH 1/5] chore: enable gocritic but disable non compliant rules Signed-off-by: Matthieu MOREL --- .golangci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index efb6567e..9c5e9d0f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,6 +3,7 @@ version: "2" linters: enable: - errorlint + - gocritic - unconvert - unparam exclusions: @@ -11,6 +12,23 @@ linters: - comments - std-error-handling settings: + gocritic: + disabled-checks: + - appendAssign + - assignOp + - builtinShadow + - deferInLoop + - emptyStringTest + - hugeParam + - ifElseChain + - importShadow + - paramTypeCombine + - rangeValCopy + - sloppyReassign + - unnamedResult + - unnecessaryDefer + - whyNoLint + enable-all: true staticcheck: # Enable all options, with some exceptions. # For defaults, see https://golangci-lint.run/usage/linters/#staticcheck From 302b68dc5c317e14af20d5cffc9818e0bcb5bb77 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:05:43 +0200 Subject: [PATCH 2/5] fix: emptyStringTest issues from gocritic Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 - capability/capability_test.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9c5e9d0f..2523ca31 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,6 @@ linters: - assignOp - builtinShadow - deferInLoop - - emptyStringTest - hugeParam - ifElseChain - importShadow diff --git a/capability/capability_test.go b/capability/capability_test.go index c9a24f90..30748120 100644 --- a/capability/capability_test.go +++ b/capability/capability_test.go @@ -133,7 +133,7 @@ func TestNewPid2Load(t *testing.T) { // Assuming that at least bounding set is not empty. bset := c.StringCap(BOUNDING) t.Logf("Bounding set: %s", bset) - if len(bset) == 0 { + if bset == "" { t.Fatal("loaded bounding set: want non-empty, got empty") } } From 791adc6f46d5086b94c7ea659be982d3ea8e48cb Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:08:37 +0200 Subject: [PATCH 3/5] fix: unnecessaryDefer issues from gocritic Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 - mount/sharedsubtree_linux_test.go | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2523ca31..873f441a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -25,7 +25,6 @@ linters: - rangeValCopy - sloppyReassign - unnamedResult - - unnecessaryDefer - whyNoLint enable-all: true staticcheck: diff --git a/mount/sharedsubtree_linux_test.go b/mount/sharedsubtree_linux_test.go index f3bed20f..ce5ac56e 100644 --- a/mount/sharedsubtree_linux_test.go +++ b/mount/sharedsubtree_linux_test.go @@ -313,9 +313,7 @@ func TestSubtreeUnbindable(t *testing.T) { } else if err == nil { t.Fatalf("%q should not have been bindable", sourceDir) } - defer func() { - if err := Unmount(targetDir); err != nil { - t.Fatal(err) - } - }() + if err := Unmount(targetDir); err != nil { + t.Fatal(err) + } } From ae447daa2554d2d86a6ab4cc06828b990e55e56b Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:10:37 +0200 Subject: [PATCH 4/5] fix: ifElseChain issues from gocritic Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 - capability/capability_linux.go | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 873f441a..4b8aa56b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,7 +19,6 @@ linters: - builtinShadow - deferInLoop - hugeParam - - ifElseChain - importShadow - paramTypeCombine - rangeValCopy diff --git a/capability/capability_linux.go b/capability/capability_linux.go index 234b1efb..eac2ce49 100644 --- a/capability/capability_linux.go +++ b/capability/capability_linux.go @@ -77,11 +77,12 @@ func mkString(c Capabilities, max CapType) (ret string) { ret = "{" for i := CapType(1); i <= max; i <<= 1 { ret += " " + i.String() + "=\"" - if c.Empty(i) { + switch { + case c.Empty(i): ret += "empty" - } else if c.Full(i) { + case c.Full(i): ret += "full" - } else { + default: ret += c.StringCap(i) } ret += "\"" From 1f2af12d1e26c34800db178205062dab0cf0e5d1 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:12:14 +0200 Subject: [PATCH 5/5] fix: assignOp issues from gocritic Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 - user/idtools_unix.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4b8aa56b..b74568ac 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,7 +15,6 @@ linters: gocritic: disabled-checks: - appendAssign - - assignOp - builtinShadow - deferInLoop - hugeParam diff --git a/user/idtools_unix.go b/user/idtools_unix.go index 4e39d244..4369b551 100644 --- a/user/idtools_unix.go +++ b/user/idtools_unix.go @@ -137,7 +137,7 @@ func lookupSubRangesFile(path string, usr User) ([]IDMap, error) { ParentID: idrange.SubID, Count: idrange.Count, }) - containerID = containerID + idrange.Count + containerID += idrange.Count } return idMap, nil }