Skip to content

Commit bc754f1

Browse files
thaJeztahjsturtevant
authored andcommitted
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]>
1 parent 20732dc commit bc754f1

File tree

16 files changed

+30
-29
lines changed

16 files changed

+30
-29
lines changed

archive/tar_unix.go

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

61-
// Rdev is int32 on darwin/bsd, int64 on linux/solaris
62-
rdev := uint64(s.Rdev) // nolint: unconvert
61+
rdev := uint64(s.Rdev) //nolint:unconvert // rdev is int32 on darwin/bsd, int64 on linux/solaris
6362

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

contrib/fuzz/content_fuzzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
// nolint: golint
17+
//nolint:golint
1818
package fuzz
1919

2020
import (

integration/client/restart_monitor_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ import (
4040
exec "golang.org/x/sys/execabs"
4141
)
4242

43-
// the following nolint is for shutting up gometalinter on non-linux.
44-
// nolint: unused
43+
//nolint:unused // Ignore on non-Linux
4544
func newDaemonWithConfig(t *testing.T, configTOML string) (*Client, *daemon, func()) {
4645
if testing.Short() {
4746
t.Skip()

oci/spec_opts.go

Lines changed: 3 additions & 4 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 {
@@ -85,7 +84,7 @@ func setResources(s *Spec) {
8584
}
8685
}
8786

88-
// nolint
87+
//nolint:unused // not used on all platforms
8988
func setResourcesWindows(s *Spec) {
9089
if s.Windows != nil {
9190
if s.Windows.Resources == nil {
@@ -94,7 +93,7 @@ func setResourcesWindows(s *Spec) {
9493
}
9594
}
9695

97-
// nolint
96+
//nolint:unused // not used on all platforms
9897
func setCPU(s *Spec) {
9998
setResources(s)
10099
if s.Linux != nil {
@@ -104,7 +103,7 @@ func setCPU(s *Spec) {
104103
}
105104
}
106105

107-
// nolint
106+
//nolint:deadcode,unused // not used on all platforms
108107
func setCPUWindows(s *Spec) {
109108
setResourcesWindows(s)
110109
if s.Windows != 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

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

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

@@ -148,7 +148,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
148148

149149
}
150150

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

oci/spec_opts_nonlinux.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,31 @@ import (
2828

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.
31-
// nolint: deadcode, unused
31+
//
32+
//nolint:unused
3233
var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
3334
return WithCapabilities(nil)(ctx, client, c, s)
3435
}
3536

3637
// WithAllKnownCapabilities sets all the known linux capabilities for the container process
37-
// nolint: deadcode, unused
38+
//
39+
//nolint:unused
3840
var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
3941
return WithCapabilities(nil)(ctx, client, c, s)
4042
}
4143

4244
// WithBlockIO sets the container's blkio parameters
43-
// nolint: deadcode, unused
45+
//
46+
//nolint:unused
4447
func WithBlockIO(blockio interface{}) SpecOpts {
4548
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
4649
return errors.New("blkio not supported")
4750
}
4851
}
4952

5053
// WithCPUShares sets the container's cpu shares
51-
// nolint: deadcode, unused
54+
//
55+
//nolint:unused
5256
func WithCPUShares(shares uint64) SpecOpts {
5357
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
5458
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/sbserver/service.go

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

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
@@ -208,6 +208,6 @@ func (s *Store) Delete(id string) {
208208
c.IO.Close()
209209
}
210210
s.labels.Release(c.ProcessLabel)
211-
s.idIndex.Delete(id) // nolint: errcheck
211+
s.idIndex.Delete(id)
212212
delete(s.containers, id)
213213
}

pkg/cri/store/image/image.go

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

pkg/cri/store/sandbox/sandbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,6 @@ func (s *Store) Delete(id string) {
160160
return
161161
}
162162
s.labels.Release(s.sandboxes[id].ProcessLabel)
163-
s.idIndex.Delete(id) // nolint: errcheck
163+
s.idIndex.Delete(id)
164164
delete(s.sandboxes, id)
165165
}

pkg/netns/netns_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func newNS(baseDir string) (nsPath string, err error) {
7777
defer func() {
7878
// Ensure the mount point is cleaned up on errors
7979
if err != nil {
80-
os.RemoveAll(nsPath) // nolint: errcheck
80+
os.RemoveAll(nsPath)
8181
}
8282
}()
8383

@@ -107,7 +107,7 @@ func newNS(baseDir string) (nsPath string, err error) {
107107
}
108108

109109
// Put this thread back to the orig ns, since it might get reused (pre go1.10)
110-
defer origNS.Set() // nolint: errcheck
110+
defer origNS.Set()
111111

112112
// bind mount the netns from the current thread (from /proc) onto the
113113
// mount point. This causes the namespace to persist, even when there
@@ -214,6 +214,6 @@ func (n *NetNS) Do(f func(cnins.NetNS) error) error {
214214
if err != nil {
215215
return fmt.Errorf("get netns fd: %w", err)
216216
}
217-
defer ns.Close() // nolint: errcheck
217+
defer ns.Close()
218218
return ns.Do(f)
219219
}

pkg/progress/escape.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ package progress
1919
const (
2020
escape = "\x1b"
2121
reset = escape + "[0m"
22-
red = escape + "[31m" // nolint: deadcode, varcheck, unused
22+
red = escape + "[31m" //nolint:deadcode,unused,varcheck
2323
green = escape + "[32m"
2424
)

pkg/runtimeoptions/v1/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
limitations under the License.
1515
*/
1616

17-
package runtimeoptions_v1 //nolint
17+
package runtimeoptions_v1 //nolint:revive // Ignore var-naming: don't use an underscore in package name (revive)

0 commit comments

Comments
 (0)