-
Notifications
You must be signed in to change notification settings - Fork 267
Switch to golangci-lint v2, fix new warnings #2299
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
Conversation
This fixes the following linter warnings:
> types/options.go:397:45: QF1009: probably want to use time.Time.Equal instead (staticcheck)
> if prevReloadConfig.storeOptions != nil && prevReloadConfig.mod == mtime && prevReloadConfig.configFile == configFile {
> ^
> types/utils.go:64:45: QF1009: probably want to use time.Time.Equal instead (staticcheck)
> if prevReloadConfig.storeOptions != nil && prevReloadConfig.mod == mtime && prevReloadConfig.configFile == configFile {
> ^
Signed-off-by: Kir Kolyshkin <[email protected]>
This fixes the following linter warning: > pkg/archive/changes.go:73:9: QF1009: probably want to use time.Time.Equal instead (staticcheck) > return a == b || > ^ Signed-off-by: Kir Kolyshkin <[email protected]>
strings.Fields treats \n as a separator, so there's no need to replace those with spaces. This fixes these linter warnings: > QF1004: could use strings.ReplaceAll unstead (staticcheck) Signed-off-by: Kir Kolyshkin <[email protected]>
This fixes the following linter warning: > types/utils.go:17:9: QF1004: could use strings.ReplaceAll instead (staticcheck) > path = strings.Replace(path, "$UID", strconv.Itoa(rootlessUID), -1) > ^ Signed-off-by: Kir Kolyshkin <[email protected]>
> drivers/aufs/aufs.go:255:18: ST1016: methods on the same type should have the same receiver name (seen 1x "d", 33x "a") (staticcheck)
> func (a *Driver) AdditionalImageStores() []string {
> ^
Signed-off-by: Kir Kolyshkin <[email protected]>
While at it, made sure there's no space between // and nolint (as it is required for comments aimed for tools not humans). This fixes the following golangci-lint warning: > WARN [runner/nolint_filter] Found unknown linters in //nolint directives: golint Signed-off-by: Kir Kolyshkin <[email protected]>
This fixes the following linter warnings:
> pkg/unshare/unshare_linux.go:270:6: QF1012: Use fmt.Fprintf(...) instead of Write([]byte(fmt.Sprintf(...))) (staticcheck)
> g.Write([]byte(fmt.Sprintf("0 %d 1\n", os.Getegid())))
> ^
> pkg/unshare/unshare_linux.go:331:6: QF1012: Use fmt.Fprintf(...) instead of Write([]byte(fmt.Sprintf(...))) (staticcheck)
> u.Write([]byte(fmt.Sprintf("0 %d 1\n", os.Geteuid())))
> ^
Signed-off-by: Kir Kolyshkin <[email protected]>
Fix a bunch of linter warnings: > ST1005: error strings should not be capitalized Signed-off-by: Kir Kolyshkin <[email protected]>
Fix the following linter warning:
> internal/dedup/dedup.go:16:5: ST1012: error var notSupported should have name of the form errFoo (staticcheck)
> var notSupported = errors.New("reflinks are not supported on this platform")
> ^
Signed-off-by: Kir Kolyshkin <[email protected]>
This fixes a bunch of linter warnings like this: > QF1001: could apply De Morgan's law Signed-off-by: Kir Kolyshkin <[email protected]>
> drivers/overlay/overlay.go:642:2: ST1015: default case should be first or last in switch statement (staticcheck) > default: > ^ Signed-off-by: Kir Kolyshkin <[email protected]>
> pkg/archive/changes_linux.go:178:3: QF1006: could lift into loop condition (staticcheck)
> if ix1 >= len(names1) {
> ^
Signed-off-by: Kir Kolyshkin <[email protected]>
> pkg/archive/changes_test.go:75:3: QF1003: could use tagged switch on info.filetype (staticcheck)
> if info.filetype == Dir {
> ^
Signed-off-by: Kir Kolyshkin <[email protected]>
> drivers/overlay/composefs.go:56:2: ST1003: var writerJson should be writerJSON (staticcheck) Signed-off-by: Kir Kolyshkin <[email protected]>
The new configuration file was initially generated by golangci-lint migrate, when tweaked to minimize and simplify. golangci-lint v2 switches to a new version of staticcheck which shows much more warnings. Some of them were fixed by a few previous commits, and the rest of them are disabled. Signed-off-by: Kir Kolyshkin <[email protected]>
|
LGTM |
Luap99
left a comment
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.
LGTM
giuseppe
left a comment
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.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, kolyshkin, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The new configuration file was initially generated by golangci-lint
migrate, when tweaked to minimize and simplify.
golangci-lint v2 switches to a new version of staticcheck which shows
much more warnings. Many of them are fixed here, and the rest
are suppressed. The suppressed ones are: