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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2022-08-30 23:05:52 +02:00
parent d215725136
commit 29c7fc9520
16 changed files with 30 additions and 29 deletions

View File

@@ -76,7 +76,6 @@ func setLinux(s *Spec) {
}
}
// nolint
func setResources(s *Spec) {
if s.Linux != nil {
if s.Linux.Resources == nil {
@@ -85,7 +84,7 @@ func setResources(s *Spec) {
}
}
// nolint
//nolint:unused // not used on all platforms
func setResourcesWindows(s *Spec) {
if s.Windows != nil {
if s.Windows.Resources == nil {
@@ -94,7 +93,7 @@ func setResourcesWindows(s *Spec) {
}
}
// nolint
//nolint:unused // not used on all platforms
func setCPU(s *Spec) {
setResources(s)
if s.Linux != nil {
@@ -104,7 +103,7 @@ func setCPU(s *Spec) {
}
}
// nolint
//nolint:deadcode,unused // not used on all platforms
func setCPUWindows(s *Spec) {
setResourcesWindows(s)
if s.Windows != nil {

View File

@@ -31,7 +31,7 @@ import (
"golang.org/x/sys/unix"
)
// nolint:gosec
//nolint:gosec
func TestWithUserID(t *testing.T) {
t.Parallel()
@@ -86,7 +86,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
}
}
// nolint:gosec
//nolint:gosec
func TestWithUsername(t *testing.T) {
t.Parallel()
@@ -148,7 +148,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
}
// nolint:gosec
//nolint:gosec
func TestWithAdditionalGIDs(t *testing.T) {
t.Parallel()
expectedPasswd := `root:x:0:0:root:/root:/bin/ash

View File

@@ -28,19 +28,22 @@ import (
// WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process.
// The capability set may differ from WithAllKnownCapabilities when running in a container.
// nolint: deadcode, unused
//
//nolint:unused
var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
return WithCapabilities(nil)(ctx, client, c, s)
}
// WithAllKnownCapabilities sets all the known linux capabilities for the container process
// nolint: deadcode, unused
//
//nolint:unused
var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
return WithCapabilities(nil)(ctx, client, c, s)
}
// WithBlockIO sets the container's blkio parameters
// nolint: deadcode, unused
//
//nolint:unused
func WithBlockIO(blockio interface{}) SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return errors.New("blkio not supported")
@@ -48,7 +51,8 @@ func WithBlockIO(blockio interface{}) SpecOpts {
}
// WithCPUShares sets the container's cpu shares
// nolint: deadcode, unused
//
//nolint:unused
func WithCPUShares(shares uint64) SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return nil

View File

@@ -127,7 +127,7 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
// TODO consider adding these consts to the OCI runtime-spec.
const (
wildcardDevice = "a" //nolint // currently unused, but should be included when upstreaming to OCI runtime-spec.
wildcardDevice = "a" //nolint:deadcode,unused,varcheck // currently unused, but should be included when upstreaming to OCI runtime-spec.
blockDevice = "b"
charDevice = "c" // or "u"
fifoDevice = "p"
@@ -148,7 +148,7 @@ func DeviceFromPath(path string) (*specs.LinuxDevice, error) {
}
var (
devNumber = uint64(stat.Rdev) //nolint: unconvert // the type is 32bit on mips.
devNumber = uint64(stat.Rdev) //nolint:unconvert // the type is 32bit on mips.
major = unix.Major(devNumber)
minor = unix.Minor(devNumber)
)