Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "2"
linters:
enable:
- errorlint
- gocritic
- unconvert
- unparam
exclusions:
Expand All @@ -11,6 +12,19 @@ linters:
- comments
- std-error-handling
settings:
gocritic:
disabled-checks:
- appendAssign
- builtinShadow
- deferInLoop
- hugeParam
- importShadow
- paramTypeCombine
- rangeValCopy
- sloppyReassign
- unnamedResult
- whyNoLint
Comment on lines +16 to +26

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the intent to address all of these (in follow-ups), or are there that cannot (yet) be addressed (e.g. due to go versions).

It's good to leave a comment for each to outline if it's either a permanent (won't fix because) or temporary (TODO).

At least some of them stood out as "should likely be fixed" (whyNoLint, rangeValCopy, importShadow), and I know the builtinShadow is a bit too opinionated (it's "OK", but sometimes not worth the code-churn.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you already know if you don't want some of them ? Otherwise the intention is indeed to try to comply with those that are the moby group and the sys project particularly usual practices.

enable-all: true
staticcheck:
# Enable all options, with some exceptions.
# For defaults, see https://golangci-lint.run/usage/linters/#staticcheck
Expand Down
7 changes: 4 additions & 3 deletions capability/capability_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "\""
Expand Down
2 changes: 1 addition & 1 deletion capability/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
8 changes: 3 additions & 5 deletions mount/sharedsubtree_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion user/idtools_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}