diff --git a/.golangci.yml b/.golangci.yml index efb6567e..c3735759 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,6 +3,7 @@ version: "2" linters: enable: - errorlint + - gocritic - unconvert - unparam exclusions: @@ -11,6 +12,18 @@ linters: - comments - std-error-handling settings: + gocritic: + disabled-checks: + - appendAssign + - builtinShadow + - deferInLoop + - hugeParam + - importShadow + - paramTypeCombine + - sloppyReassign + - unnamedResult + - whyNoLint + enable-all: true staticcheck: # Enable all options, with some exceptions. # For defaults, see https://golangci-lint.run/usage/linters/#staticcheck 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 += "\"" 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") } } 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) + } } 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 }