From e8dba98314a987db1b5f2756753c5eaa2925cdbe Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 31 Mar 2025 23:29:12 -0700 Subject: [PATCH] ci: add nolintlint, fix found issues Signed-off-by: Kir Kolyshkin --- .golangci.yml | 1 + add.go | 2 +- copier/copier.go | 4 ++-- copier/copier_test.go | 4 ++-- docker/types.go | 2 +- pkg/rusage/rusage_unix.go | 4 ++-- run_common.go | 6 +++--- run_linux.go | 4 ++-- tests/conformance/conformance_test.go | 2 +- tests/imgtype/imgtype.go | 2 +- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ddac62116..c4d2eaed4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,6 +12,7 @@ formatters: linters: enable: + - nolintlint - revive - unconvert - unparam diff --git a/add.go b/add.go index b294c56b8..0da849a64 100644 --- a/add.go +++ b/add.go @@ -622,7 +622,7 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption } // Check for dockerignore-style exclusion of this item. if rel != "." { - excluded, err := pm.Matches(filepath.ToSlash(rel)) // nolint:staticcheck + excluded, err := pm.Matches(filepath.ToSlash(rel)) //nolint:staticcheck if err != nil { return fmt.Errorf("checking if %q(%q) is excluded: %w", globbed, rel, err) } diff --git a/copier/copier.go b/copier/copier.go index bae3c8627..0689ea7ae 100644 --- a/copier/copier.go +++ b/copier/copier.go @@ -975,7 +975,7 @@ func pathIsExcluded(root, path string, pm *fileutils.PatternMatcher) (string, bo // Matches uses filepath.FromSlash() to convert candidates before // checking if they match the patterns it's been given, implying that // it expects Unix-style paths. - matches, err := pm.Matches(filepath.ToSlash(rel)) // nolint:staticcheck + matches, err := pm.Matches(filepath.ToSlash(rel)) //nolint:staticcheck if err != nil { return rel, false, fmt.Errorf("copier: error checking if %q is excluded: %w", rel, err) } @@ -2081,7 +2081,7 @@ func copierHandlerPut(bulkReader io.Reader, req request, idMappings *idtools.IDM // set xattrs, including some that might have been reset by chown() if !req.PutOptions.StripXattrs { xattrs := mapWithPrefixedKeysWithoutKeyPrefix(hdr.PAXRecords, xattrPAXRecordNamespace) - if err = Lsetxattrs(path, xattrs); err != nil { // nolint:staticcheck + if err = Lsetxattrs(path, xattrs); err != nil { if !req.PutOptions.IgnoreXattrErrors { return fmt.Errorf("copier: put: error setting extended attributes on %q: %w", path, err) } diff --git a/copier/copier_test.go b/copier/copier_test.go index 041ff2185..81004c36d 100644 --- a/copier/copier_test.go +++ b/copier/copier_test.go @@ -48,7 +48,7 @@ func makeContents(length int64) io.ReadCloser { for count < length { if _, err := buffered.Write([]byte{"0123456789abcdef"[count%16]}); err != nil { buffered.Flush() - pipeWriter.CloseWithError(err) // nolint:errcheck + pipeWriter.CloseWithError(err) return } count++ @@ -111,7 +111,7 @@ func makeArchive(headers []tar.Header, contents map[string][]byte) io.ReadCloser tw.Close() buffered.Flush() if err != nil { - pipeWriter.CloseWithError(err) // nolint:errcheck + pipeWriter.CloseWithError(err) } else { pipeWriter.Close() } diff --git a/docker/types.go b/docker/types.go index 275951d03..9460adb7b 100644 --- a/docker/types.go +++ b/docker/types.go @@ -164,7 +164,7 @@ type V1Image struct { // V2Image stores the image configuration type V2Image struct { V1Image - Parent ID `json:"parent,omitempty"` // nolint:govet + Parent ID `json:"parent,omitempty"` RootFS *V2S2RootFS `json:"rootfs,omitempty"` History []V2S2History `json:"history,omitempty"` OSVersion string `json:"os.version,omitempty"` diff --git a/pkg/rusage/rusage_unix.go b/pkg/rusage/rusage_unix.go index 71fa60f1a..415c94935 100644 --- a/pkg/rusage/rusage_unix.go +++ b/pkg/rusage/rusage_unix.go @@ -22,8 +22,8 @@ func get() (Rusage, error) { Date: time.Now(), Utime: mkduration(rusage.Utime), Stime: mkduration(rusage.Stime), - Inblock: int64(rusage.Inblock), // nolint: unconvert - Outblock: int64(rusage.Oublock), // nolint: unconvert + Inblock: int64(rusage.Inblock), //nolint:unconvert + Outblock: int64(rusage.Oublock), //nolint:unconvert } return r, nil } diff --git a/run_common.go b/run_common.go index a14d66b2f..2ac922c7c 100644 --- a/run_common.go +++ b/run_common.go @@ -870,13 +870,13 @@ func runCopyStdio(logger *logrus.Logger, stdio *sync.WaitGroup, copyPipes bool, return } if blocked { - defer setNonblock(logger, rfd, readDesc[rfd], false) // nolint:errcheck + defer setNonblock(logger, rfd, readDesc[rfd], false) //nolint:errcheck } - setNonblock(logger, wfd, writeDesc[wfd], false) // nolint:errcheck + setNonblock(logger, wfd, writeDesc[wfd], false) //nolint:errcheck } if copyPipes { - setNonblock(logger, stdioPipe[unix.Stdin][1], writeDesc[stdioPipe[unix.Stdin][1]], true) // nolint:errcheck + setNonblock(logger, stdioPipe[unix.Stdin][1], writeDesc[stdioPipe[unix.Stdin][1]], true) //nolint:errcheck } runCopyStdioPassData(copyPipes, stdioPipe, finishCopy, relayMap, relayBuffer, readDesc, writeDesc) diff --git a/run_linux.go b/run_linux.go index 6316136e7..526b71855 100644 --- a/run_linux.go +++ b/run_linux.go @@ -691,9 +691,9 @@ func setupSlirp4netnsNetwork(config *config.Config, netns, cid string, options, } return func() { - syscall.Kill(res.Pid, syscall.SIGKILL) // nolint:errcheck + syscall.Kill(res.Pid, syscall.SIGKILL) //nolint:errcheck var status syscall.WaitStatus - syscall.Wait4(res.Pid, &status, 0, nil) // nolint:errcheck + syscall.Wait4(res.Pid, &status, 0, nil) //nolint:errcheck }, result, nil } diff --git a/tests/conformance/conformance_test.go b/tests/conformance/conformance_test.go index 3e99be501..c2c8a4a5b 100644 --- a/tests/conformance/conformance_test.go +++ b/tests/conformance/conformance_test.go @@ -934,7 +934,7 @@ func fsHeaderForEntry(hdr *tar.Header) FSHeader { ModTime: hdr.ModTime, Devmajor: hdr.Devmajor, Devminor: hdr.Devminor, - Xattrs: hdr.Xattrs, // nolint:staticcheck + Xattrs: hdr.Xattrs, //nolint:staticcheck } } diff --git a/tests/imgtype/imgtype.go b/tests/imgtype/imgtype.go index 02574fe94..3b38db008 100644 --- a/tests/imgtype/imgtype.go +++ b/tests/imgtype/imgtype.go @@ -97,7 +97,7 @@ func main() { errors := false defer func() { - store.Shutdown(false) // nolint:errcheck + store.Shutdown(false) //nolint:errcheck if errors { os.Exit(1) }