From 2e46589f19faddc9ccd8d70486caf570ec88ef2d Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:04:05 +0200 Subject: [PATCH 1/7] chore: enable gocritic but disable non compliant rules Signed-off-by: Matthieu MOREL --- .golangci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index efb6567e..7d478862 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,6 +3,7 @@ version: "2" linters: enable: - errorlint + - gocritic - unconvert - unparam exclusions: @@ -11,6 +12,22 @@ linters: - comments - std-error-handling settings: + gocritic: + disabled-checks: + - appendAssign + - assignOp + - builtinShadow + - deferInLoop + - emptyStringTest + - hugeParam + - ifElseChain + - importShadow + - paramTypeCombine + - sloppyReassign + - unnamedResult + - unnecessaryDefer + - whyNoLint + enable-all: true staticcheck: # Enable all options, with some exceptions. # For defaults, see https://golangci-lint.run/usage/linters/#staticcheck @@ -24,3 +41,7 @@ formatters: - gofumpt exclusions: generated: disable + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 From d28b4a9f1c5d4574f1bb4e4dbb805812e1c31283 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:05:43 +0200 Subject: [PATCH 2/7] 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 7d478862..59cd10ad 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 288783face03fdae4041acf8becf5ac0b42530ff Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:08:37 +0200 Subject: [PATCH 3/7] 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 59cd10ad..0bd92737 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,7 +24,6 @@ linters: - paramTypeCombine - 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 ab546caf2c4850ff428078638948d68300a6f45e Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:10:37 +0200 Subject: [PATCH 4/7] 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 0bd92737..2dc9656b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,7 +19,6 @@ linters: - builtinShadow - deferInLoop - hugeParam - - ifElseChain - importShadow - paramTypeCombine - sloppyReassign 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 171f09e49bc9f011c584f4775731e1a90cc56f9e Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:12:14 +0200 Subject: [PATCH 5/7] 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 2dc9656b..d818eab8 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 } From 96e38d9d8ed4ad26ddbf23901301e194fbd917de Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 11 Aug 2026 19:15:04 +0200 Subject: [PATCH 6/7] restore default issues limits Signed-off-by: Matthieu MOREL --- .golangci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d818eab8..0e4765d3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -36,8 +36,4 @@ formatters: enable: - gofumpt exclusions: - generated: disable - -issues: - max-issues-per-linter: 0 - max-same-issues: 0 + generated: disable \ No newline at end of file From 506e5b4768156550c00487a10463a2775b5c95f1 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Wed, 12 Aug 2026 05:39:29 +0200 Subject: [PATCH 7/7] Fix formatting in .golangci.yml Signed-off-by: Matthieu MOREL --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 0e4765d3..c3735759 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -36,4 +36,4 @@ formatters: enable: - gofumpt exclusions: - generated: disable \ No newline at end of file + generated: disable