Skip to content

Commit 95655f4

Browse files
committed
clean-up "nolint" comments, remove unused ones
- fix "nolint" comments to be in the correct format (`//nolint:<linters>[,<linter>` no leading space, required colon (`:`) and linters. - remove "nolint" comments for errcheck, which is disabled in our config. - remove "nolint" comments that were no longer needed (nolintlint). - where known, add a comment describing why a "nolint" was applied. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 29c7fc9) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9f0617e commit 95655f4

14 files changed

Lines changed: 21 additions & 25 deletions

File tree

archive/tar_unix.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, fi os.FileInfo) err
6262
return errors.New("unsupported stat type")
6363
}
6464

65-
// Rdev is int32 on darwin/bsd, int64 on linux/solaris
66-
rdev := uint64(s.Rdev) //nolint:unconvert
65+
rdev := uint64(s.Rdev) //nolint:unconvert // rdev is int32 on darwin/bsd, int64 on linux/solaris
6766

6867
// Currently go does not fill in the major/minors
6968
if s.Mode&syscall.S_IFBLK != 0 ||

integration/client/restart_monitor_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ import (
3636
exec "golang.org/x/sys/execabs"
3737
)
3838

39-
// the following nolint is for shutting up gometalinter on non-linux.
40-
//
41-
//nolint:unused
39+
//nolint:unused // Ignore on non-Linux
4240
func newDaemonWithConfig(t *testing.T, configTOML string) (*Client, *daemon, func()) {
4341
if testing.Short() {
4442
t.Skip()

oci/spec_opts.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ func setLinux(s *Spec) {
7676
}
7777
}
7878

79-
// nolint
8079
func setResources(s *Spec) {
8180
if s.Linux != nil {
8281
if s.Linux.Resources == nil {
@@ -90,7 +89,7 @@ func setResources(s *Spec) {
9089
}
9190
}
9291

93-
// nolint
92+
//nolint:unused // not used on all platforms
9493
func setCPU(s *Spec) {
9594
setResources(s)
9695
if s.Linux != nil {

oci/spec_opts_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"golang.org/x/sys/unix"
3232
)
3333

34-
// nolint:gosec
34+
//nolint:gosec
3535
func TestWithUserID(t *testing.T) {
3636
t.Parallel()
3737

@@ -87,7 +87,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
8787
}
8888
}
8989

90-
// nolint:gosec
90+
//nolint:gosec
9191
func TestWithUsername(t *testing.T) {
9292
t.Parallel()
9393

@@ -150,7 +150,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
150150

151151
}
152152

153-
// nolint:gosec
153+
//nolint:gosec
154154
func TestWithAdditionalGIDs(t *testing.T) {
155155
t.Parallel()
156156
expectedPasswd := `root:x:0:0:root:/root:/bin/ash

oci/spec_opts_nonlinux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ import (
2929
// WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process.
3030
// The capability set may differ from WithAllKnownCapabilities when running in a container.
3131
//
32-
//nolint:deadcode,unused
32+
//nolint:unused
3333
var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
3434
return WithCapabilities(nil)(ctx, client, c, s)
3535
}
3636

3737
// WithAllKnownCapabilities sets all the known linux capabilities for the container process
3838
//
39-
//nolint:deadcode,unused
39+
//nolint:unused
4040
var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
4141
return WithCapabilities(nil)(ctx, client, c, s)
4242
}
4343

4444
// WithCPUShares sets the container's cpu shares
4545
//
46-
//nolint:deadcode,unused
46+
//nolint:unused
4747
func WithCPUShares(shares uint64) SpecOpts {
4848
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
4949
return nil

oci/utils_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
127127

128128
// TODO consider adding these consts to the OCI runtime-spec.
129129
const (
130-
wildcardDevice = "a" //nolint // currently unused, but should be included when upstreaming to OCI runtime-spec.
130+
wildcardDevice = "a" //nolint:deadcode,unused,varcheck // currently unused, but should be included when upstreaming to OCI runtime-spec.
131131
blockDevice = "b"
132132
charDevice = "c" // or "u"
133133
fifoDevice = "p"
@@ -148,7 +148,7 @@ func DeviceFromPath(path string) (*specs.LinuxDevice, error) {
148148
}
149149

150150
var (
151-
devNumber = uint64(stat.Rdev) //nolint: unconvert // the type is 32bit on mips.
151+
devNumber = uint64(stat.Rdev) //nolint:unconvert // the type is 32bit on mips.
152152
major = unix.Major(devNumber)
153153
minor = unix.Minor(devNumber)
154154
)

pkg/cri/opts/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
8383
// if it fails but not RM snapshot data.
8484
// refer to https://github.com/containerd/containerd/pull/1868
8585
// https://github.com/containerd/containerd/pull/1785
86-
defer os.Remove(root) //nolint:errcheck
86+
defer os.Remove(root)
8787

8888
unmounter := func(mountPath string) {
8989
if uerr := mount.Unmount(mountPath, 0); uerr != nil {

pkg/cri/server/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ type criService struct {
113113
baseOCISpecs map[string]*oci.Spec
114114
// allCaps is the list of the capabilities.
115115
// When nil, parsed from CapEff of /proc/self/status.
116-
allCaps []string // nolint
116+
allCaps []string //nolint:unused // Ignore on non-Linux
117117
// unpackDuplicationSuppressor is used to make sure that there is only
118118
// one in-flight fetch request or unpack handler for a given descriptor's
119119
// or chain ID.

pkg/cri/store/container/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,6 @@ func (s *Store) Delete(id string) {
205205
c.IO.Close()
206206
}
207207
s.labels.Release(c.ProcessLabel)
208-
s.idIndex.Delete(id) //nolint:errcheck
208+
s.idIndex.Delete(id)
209209
delete(s.containers, id)
210210
}

pkg/cri/store/image/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,6 @@ func (s *store) delete(id, ref string) {
250250
return
251251
}
252252
// Remove the image if it is not referenced any more.
253-
s.digestSet.Remove(digest) //nolint:errcheck
253+
s.digestSet.Remove(digest)
254254
delete(s.images, digest.String())
255255
}

0 commit comments

Comments
 (0)