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:
parent
d215725136
commit
29c7fc9520
@ -58,8 +58,7 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, fi os.FileInfo) err
|
|||||||
return errors.New("unsupported stat type")
|
return errors.New("unsupported stat type")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rdev is int32 on darwin/bsd, int64 on linux/solaris
|
rdev := uint64(s.Rdev) //nolint:unconvert // rdev is int32 on darwin/bsd, int64 on linux/solaris
|
||||||
rdev := uint64(s.Rdev) // nolint: unconvert
|
|
||||||
|
|
||||||
// Currently go does not fill in the major/minors
|
// Currently go does not fill in the major/minors
|
||||||
if s.Mode&syscall.S_IFBLK != 0 ||
|
if s.Mode&syscall.S_IFBLK != 0 ||
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// nolint: golint
|
//nolint:golint
|
||||||
package fuzz
|
package fuzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -40,8 +40,7 @@ import (
|
|||||||
exec "golang.org/x/sys/execabs"
|
exec "golang.org/x/sys/execabs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// the following nolint is for shutting up gometalinter on non-linux.
|
//nolint:unused // Ignore on non-Linux
|
||||||
// nolint: unused
|
|
||||||
func newDaemonWithConfig(t *testing.T, configTOML string) (*Client, *daemon, func()) {
|
func newDaemonWithConfig(t *testing.T, configTOML string) (*Client, *daemon, func()) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip()
|
t.Skip()
|
||||||
|
@ -76,7 +76,6 @@ func setLinux(s *Spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint
|
|
||||||
func setResources(s *Spec) {
|
func setResources(s *Spec) {
|
||||||
if s.Linux != nil {
|
if s.Linux != nil {
|
||||||
if s.Linux.Resources == 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) {
|
func setResourcesWindows(s *Spec) {
|
||||||
if s.Windows != nil {
|
if s.Windows != nil {
|
||||||
if s.Windows.Resources == 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) {
|
func setCPU(s *Spec) {
|
||||||
setResources(s)
|
setResources(s)
|
||||||
if s.Linux != nil {
|
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) {
|
func setCPUWindows(s *Spec) {
|
||||||
setResourcesWindows(s)
|
setResourcesWindows(s)
|
||||||
if s.Windows != nil {
|
if s.Windows != nil {
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nolint:gosec
|
//nolint:gosec
|
||||||
func TestWithUserID(t *testing.T) {
|
func TestWithUserID(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gosec
|
//nolint:gosec
|
||||||
func TestWithUsername(t *testing.T) {
|
func TestWithUsername(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ guest:x:405:100:guest:/dev/null:/sbin/nologin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gosec
|
//nolint:gosec
|
||||||
func TestWithAdditionalGIDs(t *testing.T) {
|
func TestWithAdditionalGIDs(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
expectedPasswd := `root:x:0:0:root:/root:/bin/ash
|
expectedPasswd := `root:x:0:0:root:/root:/bin/ash
|
||||||
|
@ -28,19 +28,22 @@ import (
|
|||||||
|
|
||||||
// WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process.
|
// 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.
|
// 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 {
|
var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||||
return WithCapabilities(nil)(ctx, client, c, s)
|
return WithCapabilities(nil)(ctx, client, c, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithAllKnownCapabilities sets all the known linux capabilities for the container process
|
// 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 {
|
var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||||
return WithCapabilities(nil)(ctx, client, c, s)
|
return WithCapabilities(nil)(ctx, client, c, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithBlockIO sets the container's blkio parameters
|
// WithBlockIO sets the container's blkio parameters
|
||||||
// nolint: deadcode, unused
|
//
|
||||||
|
//nolint:unused
|
||||||
func WithBlockIO(blockio interface{}) SpecOpts {
|
func WithBlockIO(blockio interface{}) SpecOpts {
|
||||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||||
return errors.New("blkio not supported")
|
return errors.New("blkio not supported")
|
||||||
@ -48,7 +51,8 @@ func WithBlockIO(blockio interface{}) SpecOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithCPUShares sets the container's cpu shares
|
// WithCPUShares sets the container's cpu shares
|
||||||
// nolint: deadcode, unused
|
//
|
||||||
|
//nolint:unused
|
||||||
func WithCPUShares(shares uint64) SpecOpts {
|
func WithCPUShares(shares uint64) SpecOpts {
|
||||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -127,7 +127,7 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
|
|||||||
|
|
||||||
// TODO consider adding these consts to the OCI runtime-spec.
|
// TODO consider adding these consts to the OCI runtime-spec.
|
||||||
const (
|
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"
|
blockDevice = "b"
|
||||||
charDevice = "c" // or "u"
|
charDevice = "c" // or "u"
|
||||||
fifoDevice = "p"
|
fifoDevice = "p"
|
||||||
@ -148,7 +148,7 @@ func DeviceFromPath(path string) (*specs.LinuxDevice, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
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)
|
major = unix.Major(devNumber)
|
||||||
minor = unix.Minor(devNumber)
|
minor = unix.Minor(devNumber)
|
||||||
)
|
)
|
||||||
|
@ -83,7 +83,7 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
|
|||||||
// if it fails but not RM snapshot data.
|
// if it fails but not RM snapshot data.
|
||||||
// refer to https://github.com/containerd/containerd/pull/1868
|
// refer to https://github.com/containerd/containerd/pull/1868
|
||||||
// https://github.com/containerd/containerd/pull/1785
|
// https://github.com/containerd/containerd/pull/1785
|
||||||
defer os.Remove(root) // nolint: errcheck
|
defer os.Remove(root)
|
||||||
|
|
||||||
unmounter := func(mountPath string) {
|
unmounter := func(mountPath string) {
|
||||||
if uerr := mount.Unmount(mountPath, 0); uerr != nil {
|
if uerr := mount.Unmount(mountPath, 0); uerr != nil {
|
||||||
|
@ -117,7 +117,7 @@ type criService struct {
|
|||||||
baseOCISpecs map[string]*oci.Spec
|
baseOCISpecs map[string]*oci.Spec
|
||||||
// allCaps is the list of the capabilities.
|
// allCaps is the list of the capabilities.
|
||||||
// When nil, parsed from CapEff of /proc/self/status.
|
// When nil, parsed from CapEff of /proc/self/status.
|
||||||
allCaps []string // nolint
|
allCaps []string //nolint:unused // Ignore on non-Linux
|
||||||
// unpackDuplicationSuppressor is used to make sure that there is only
|
// unpackDuplicationSuppressor is used to make sure that there is only
|
||||||
// one in-flight fetch request or unpack handler for a given descriptor's
|
// one in-flight fetch request or unpack handler for a given descriptor's
|
||||||
// or chain ID.
|
// or chain ID.
|
||||||
|
@ -113,7 +113,7 @@ type criService struct {
|
|||||||
baseOCISpecs map[string]*oci.Spec
|
baseOCISpecs map[string]*oci.Spec
|
||||||
// allCaps is the list of the capabilities.
|
// allCaps is the list of the capabilities.
|
||||||
// When nil, parsed from CapEff of /proc/self/status.
|
// When nil, parsed from CapEff of /proc/self/status.
|
||||||
allCaps []string // nolint
|
allCaps []string //nolint:unused // Ignore on non-Linux
|
||||||
// unpackDuplicationSuppressor is used to make sure that there is only
|
// unpackDuplicationSuppressor is used to make sure that there is only
|
||||||
// one in-flight fetch request or unpack handler for a given descriptor's
|
// one in-flight fetch request or unpack handler for a given descriptor's
|
||||||
// or chain ID.
|
// or chain ID.
|
||||||
|
@ -208,6 +208,6 @@ func (s *Store) Delete(id string) {
|
|||||||
c.IO.Close()
|
c.IO.Close()
|
||||||
}
|
}
|
||||||
s.labels.Release(c.ProcessLabel)
|
s.labels.Release(c.ProcessLabel)
|
||||||
s.idIndex.Delete(id) // nolint: errcheck
|
s.idIndex.Delete(id)
|
||||||
delete(s.containers, id)
|
delete(s.containers, id)
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,6 @@ func (s *store) delete(id, ref string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Remove the image if it is not referenced any more.
|
// Remove the image if it is not referenced any more.
|
||||||
s.digestSet.Remove(digest) // nolint: errcheck
|
s.digestSet.Remove(digest)
|
||||||
delete(s.images, digest.String())
|
delete(s.images, digest.String())
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,6 @@ func (s *Store) Delete(id string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.labels.Release(s.sandboxes[id].ProcessLabel)
|
s.labels.Release(s.sandboxes[id].ProcessLabel)
|
||||||
s.idIndex.Delete(id) // nolint: errcheck
|
s.idIndex.Delete(id)
|
||||||
delete(s.sandboxes, id)
|
delete(s.sandboxes, id)
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func newNS(baseDir string) (nsPath string, err error) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
// Ensure the mount point is cleaned up on errors
|
// Ensure the mount point is cleaned up on errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.RemoveAll(nsPath) // nolint: errcheck
|
os.RemoveAll(nsPath)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ func newNS(baseDir string) (nsPath string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Put this thread back to the orig ns, since it might get reused (pre go1.10)
|
// Put this thread back to the orig ns, since it might get reused (pre go1.10)
|
||||||
defer origNS.Set() // nolint: errcheck
|
defer origNS.Set()
|
||||||
|
|
||||||
// bind mount the netns from the current thread (from /proc) onto the
|
// bind mount the netns from the current thread (from /proc) onto the
|
||||||
// mount point. This causes the namespace to persist, even when there
|
// 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 {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get netns fd: %w", err)
|
return fmt.Errorf("get netns fd: %w", err)
|
||||||
}
|
}
|
||||||
defer ns.Close() // nolint: errcheck
|
defer ns.Close()
|
||||||
return ns.Do(f)
|
return ns.Do(f)
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,6 @@ package progress
|
|||||||
const (
|
const (
|
||||||
escape = "\x1b"
|
escape = "\x1b"
|
||||||
reset = escape + "[0m"
|
reset = escape + "[0m"
|
||||||
red = escape + "[31m" // nolint: deadcode, varcheck, unused
|
red = escape + "[31m" //nolint:deadcode,unused,varcheck
|
||||||
green = escape + "[32m"
|
green = escape + "[32m"
|
||||||
)
|
)
|
||||||
|
@ -14,4 +14,4 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package runtimeoptions_v1 //nolint
|
package runtimeoptions_v1 //nolint:revive // Ignore var-naming: don't use an underscore in package name (revive)
|
||||||
|
Loading…
Reference in New Issue
Block a user