-
Notifications
You must be signed in to change notification settings - Fork 2.3k
ci: bump golangci-lint to v2.9, fix some prealloc linter warnings #5118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,7 +174,7 @@ func initMaps() { | |
| // Used by `runc features`. | ||
| func KnownNamespaces() []string { | ||
| initMaps() | ||
| var res []string | ||
| var res []string //nolint:prealloc | ||
| for k := range namespaceMapping { | ||
| res = append(res, string(k)) | ||
| } | ||
|
|
@@ -186,7 +186,7 @@ func KnownNamespaces() []string { | |
| // Used by `runc features`. | ||
| func KnownMountOptions() []string { | ||
| initMaps() | ||
| var res []string | ||
| var res []string //nolint:prealloc | ||
| for k := range mountFlags { | ||
|
Comment on lines
-189
to
190
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idem
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually should look like this: res := make([]string, 0, len(mountFlags) + len(mountPropagationMapping) + len(recAttrFlags) + len(extensionFLags)and this is kind of ugly, with no real performance benefit (as this is only used from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The alternative to this is: func KnownMountOptions() []string {
initMaps()
all := slices.Concat(
slices.Collect(maps.Keys(mountFlags)),
slices.Collect(maps.Keys(mountPropagationMapping)),
slices.Collect(maps.Keys(recAttrFlags)),
slices.Collect(maps.Keys(extensionFlags)),
)
slices.Sort(all)
return all
}which I don't like either as it creates some intermediate slices.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was unsure the noise/signal ratio of this linter was going to be useful. Clearly it can force us to write horrible code (like here). I'm not sure this linter is worth having.... :-/
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed (I agree it's more of a "recommendation" kind of linter). Kept some of the fixes which make sense.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kolyshkin did you push? |
||
| res = append(res, k) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
len(namespaceMapping)for the prealloc doesn't work here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ^^^ is one the functions used by
runc featuresonly, so I chose to ignore rather than fix prealloc warnings.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this one is it? Oh, okay. If we have the linter, I'd still do it... Not sure we want the linter, though