Switch to golangci-lint v2, fix new warnings#2299
Merged
openshift-merge-bot[bot] merged 15 commits intocontainers:mainfrom Mar 27, 2025
Merged
Switch to golangci-lint v2, fix new warnings#2299openshift-merge-bot[bot] merged 15 commits intocontainers:mainfrom
openshift-merge-bot[bot] merged 15 commits intocontainers:mainfrom
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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
> 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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
Fix a bunch of linter warnings: > ST1005: error strings should not be capitalized Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
This fixes a bunch of linter warnings like this: > QF1001: could apply De Morgan's law Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
> drivers/overlay/overlay.go:642:2: ST1015: default case should be first or last in switch statement (staticcheck) > default: > ^ Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
> pkg/archive/changes_linux.go:178:3: QF1006: could lift into loop condition (staticcheck)
> if ix1 >= len(names1) {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
> 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 <kolyshkin@gmail.com>
> drivers/overlay/composefs.go:56:2: ST1003: var writerJson should be writerJSON (staticcheck) Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
Member
|
LGTM |
Contributor
|
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: