Skip to content

Conversation

@kolyshkin
Copy link
Contributor

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:

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]>
@rhatdan
Copy link
Member

rhatdan commented Mar 27, 2025

LGTM

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 27, 2025

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 5cfab52 into containers:main Mar 27, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants