Skip to content

Commit

Permalink
remove unneeded nolint-comments (nolintlint), disable deprecated linters
Browse files Browse the repository at this point in the history
Remove nolint-comments that weren't hit by linters, and remove the "structcheck"
and "varcheck" linters, as they have been deprecated:

    WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
    WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
    WARN [linters context] structcheck is disabled because of generics. You can track the evolution of the generics support by following the golangci/golangci-lint#2649.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah authored and jsturtevant committed Sep 21, 2023
1 parent bc754f1 commit 41b3cd2
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 45 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Expand Up @@ -6,13 +6,12 @@ linters:
- gosec
- ineffassign
- misspell
- nolintlint
- revive
- staticcheck
- structcheck
- tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17
- unconvert
- unused
- varcheck
- vet
disable:
- errcheck
Expand Down
2 changes: 1 addition & 1 deletion archive/tar_unix.go
Expand Up @@ -58,7 +58,7 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, fi os.FileInfo) err
return errors.New("unsupported stat type")
}

rdev := uint64(s.Rdev) //nolint:unconvert // rdev is int32 on darwin/bsd, int64 on linux/solaris
rdev := uint64(s.Rdev) //nolint:nolintlint,unconvert // rdev is int32 on darwin/bsd, int64 on linux/solaris

// Currently go does not fill in the major/minors
if s.Mode&syscall.S_IFBLK != 0 ||
Expand Down
16 changes: 8 additions & 8 deletions integration/main_test.go
Expand Up @@ -210,7 +210,7 @@ func PodSandboxConfigWithCleanup(t *testing.T, name, ns string, opts ...PodSandb
}

// Set Windows HostProcess on the pod.
func WithWindowsHostProcessPod(p *runtime.PodSandboxConfig) { //nolint:unused
func WithWindowsHostProcessPod(p *runtime.PodSandboxConfig) {
if p.Windows == nil {
p.Windows = &runtime.WindowsPodSandboxConfig{}
}
Expand All @@ -237,7 +237,7 @@ func WithTestAnnotations() ContainerOpts {
}

// Add container resource limits.
func WithResources(r *runtime.LinuxContainerResources) ContainerOpts { //nolint:unused
func WithResources(r *runtime.LinuxContainerResources) ContainerOpts {
return func(c *runtime.ContainerConfig) {
if c.Linux == nil {
c.Linux = &runtime.LinuxContainerConfig{}
Expand All @@ -247,7 +247,7 @@ func WithResources(r *runtime.LinuxContainerResources) ContainerOpts { //nolint:
}

// Adds Windows container resource limits.
func WithWindowsResources(r *runtime.WindowsContainerResources) ContainerOpts { //nolint:unused
func WithWindowsResources(r *runtime.WindowsContainerResources) ContainerOpts {
return func(c *runtime.ContainerConfig) {
if c.Windows == nil {
c.Windows = &runtime.WindowsContainerConfig{}
Expand All @@ -265,7 +265,7 @@ func WithVolumeMount(hostPath, containerPath string) ContainerOpts {
}
}

func WithWindowsUsername(username string) ContainerOpts { //nolint:unused
func WithWindowsUsername(username string) ContainerOpts {
return func(c *runtime.ContainerConfig) {
if c.Windows == nil {
c.Windows = &runtime.WindowsContainerConfig{}
Expand All @@ -277,7 +277,7 @@ func WithWindowsUsername(username string) ContainerOpts { //nolint:unused
}
}

func WithWindowsHostProcessContainer() ContainerOpts { //nolint:unused
func WithWindowsHostProcessContainer() ContainerOpts {
return func(c *runtime.ContainerConfig) {
if c.Windows == nil {
c.Windows = &runtime.WindowsContainerConfig{}
Expand Down Expand Up @@ -322,7 +322,7 @@ func WithLogPath(path string) ContainerOpts {
}

// WithSupplementalGroups adds supplemental groups.
func WithSupplementalGroups(gids []int64) ContainerOpts { //nolint:unused
func WithSupplementalGroups(gids []int64) ContainerOpts {
return func(c *runtime.ContainerConfig) {
if c.Linux == nil {
c.Linux = &runtime.LinuxContainerConfig{}
Expand All @@ -335,7 +335,7 @@ func WithSupplementalGroups(gids []int64) ContainerOpts { //nolint:unused
}

// WithDevice adds a device mount.
func WithDevice(containerPath, hostPath, permissions string) ContainerOpts { //nolint:unused
func WithDevice(containerPath, hostPath, permissions string) ContainerOpts {
return func(c *runtime.ContainerConfig) {
c.Devices = append(c.Devices, &runtime.Device{
ContainerPath: containerPath, HostPath: hostPath, Permissions: permissions,
Expand Down Expand Up @@ -558,7 +558,7 @@ func CRIConfig() (*criconfig.Config, error) {
}

// SandboxInfo gets sandbox info.
func SandboxInfo(id string) (*runtime.PodSandboxStatus, *server.SandboxInfo, error) { //nolint:unused
func SandboxInfo(id string) (*runtime.PodSandboxStatus, *server.SandboxInfo, error) {
client, err := RawRuntimeClient()
if err != nil {
return nil, nil, fmt.Errorf("failed to get raw runtime client: %w", err)
Expand Down
6 changes: 3 additions & 3 deletions oci/spec_opts.go
Expand Up @@ -84,7 +84,7 @@ func setResources(s *Spec) {
}
}

//nolint:unused // not used on all platforms
//nolint:nolintlint,unused // not used on all platforms
func setResourcesWindows(s *Spec) {
if s.Windows != nil {
if s.Windows.Resources == nil {
Expand All @@ -93,7 +93,7 @@ func setResourcesWindows(s *Spec) {
}
}

//nolint:unused // not used on all platforms
//nolint:nolintlint,unused // not used on all platforms
func setCPU(s *Spec) {
setResources(s)
if s.Linux != nil {
Expand All @@ -103,7 +103,7 @@ func setCPU(s *Spec) {
}
}

//nolint:deadcode,unused // not used on all platforms
//nolint:deadcode,nolintlint,unused // not used on all platforms
func setCPUWindows(s *Spec) {
setResourcesWindows(s)
if s.Windows != nil {
Expand Down
8 changes: 0 additions & 8 deletions oci/spec_opts_nonlinux.go
Expand Up @@ -28,31 +28,23 @@ 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: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: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:unused
func WithBlockIO(blockio interface{}) SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return errors.New("blkio not supported")
}
}

// WithCPUShares sets the container's cpu shares
//
//nolint:unused
func WithCPUShares(shares uint64) SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return nil
Expand Down
4 changes: 2 additions & 2 deletions oci/utils_unix.go
Expand Up @@ -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:deadcode,unused,varcheck // currently unused, but should be included when upstreaming to OCI runtime-spec.
wildcardDevice = "a" //nolint:deadcode,nolintlint,unused,varcheck // currently unused, but should be included when upstreaming to OCI runtime-spec.
blockDevice = "b"
charDevice = "c" // or "u"
fifoDevice = "p"
Expand All @@ -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:nolintlint,unconvert // the type is 32bit on mips.
major = unix.Major(devNumber)
minor = unix.Minor(devNumber)
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/sbserver/container_stats.go
Expand Up @@ -41,7 +41,7 @@ func (c *criService) ContainerStats(ctx context.Context, in *runtime.ContainerSt
}

cs, err := c.containerMetrics(cntr.Metadata, resp.Metrics[0])
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (stats unimplemented)
if err != nil {
return nil, fmt.Errorf("failed to decode container metrics: %w", err)
}
return &runtime.ContainerStatsResponse{Stats: cs}, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/sbserver/container_stats_list.go
Expand Up @@ -58,7 +58,7 @@ func (c *criService) toCRIContainerStats(
containerStats := new(runtime.ListContainerStatsResponse)
for _, cntr := range containers {
cs, err := c.containerMetrics(cntr.Metadata, statsMap[cntr.ID])
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (metrics unimplemented)
if err != nil {
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
}
containerStats.Stats = append(containerStats.Stats, cs)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cri/sbserver/sandbox_stats.go
Expand Up @@ -34,12 +34,12 @@ func (c *criService) PodSandboxStats(
}

metrics, err := metricsForSandbox(sandbox)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed getting metrics for sandbox %s: %w", r.GetPodSandboxId(), err)
}

podSandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed to decode pod sandbox metrics %s: %w", r.GetPodSandboxId(), err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cri/sbserver/sandbox_stats_list.go
Expand Up @@ -34,12 +34,12 @@ func (c *criService) ListPodSandboxStats(
podSandboxStats := new(runtime.ListPodSandboxStatsResponse)
for _, sandbox := range sandboxes {
metrics, err := metricsForSandbox(sandbox)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed to obtain metrics for sandbox %q: %w", sandbox.ID, err)
}

sandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err)
}
podSandboxStats.Stats = append(podSandboxStats.Stats, sandboxStats)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/sbserver/service.go
Expand Up @@ -117,7 +117,7 @@ type criService struct {
baseOCISpecs map[string]*oci.Spec
// allCaps is the list of the capabilities.
// When nil, parsed from CapEff of /proc/self/status.
allCaps []string //nolint:unused // Ignore on non-Linux
allCaps []string //nolint:nolintlint,unused // Ignore on non-Linux
// unpackDuplicationSuppressor is used to make sure that there is only
// one in-flight fetch request or unpack handler for a given descriptor's
// or chain ID.
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/server/container_stats.go
Expand Up @@ -41,7 +41,7 @@ func (c *criService) ContainerStats(ctx context.Context, in *runtime.ContainerSt
}

cs, err := c.containerMetrics(cntr.Metadata, resp.Metrics[0])
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (stats unimplemented)
if err != nil {
return nil, fmt.Errorf("failed to decode container metrics: %w", err)
}
return &runtime.ContainerStatsResponse{Stats: cs}, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/server/container_stats_list.go
Expand Up @@ -61,7 +61,7 @@ func (c *criService) toCRIContainerStats(
containerStats := new(runtime.ListContainerStatsResponse)
for _, cntr := range containers {
cs, err := c.containerMetrics(cntr.Metadata, statsMap[cntr.ID])
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (metrics unimplemented)
if err != nil {
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cri/server/sandbox_stats.go
Expand Up @@ -34,12 +34,12 @@ func (c *criService) PodSandboxStats(
}

metrics, err := metricsForSandbox(sandbox)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed getting metrics for sandbox %s: %w", r.GetPodSandboxId(), err)
}

podSandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed to decode pod sandbox metrics %s: %w", r.GetPodSandboxId(), err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cri/server/sandbox_stats_list.go
Expand Up @@ -34,12 +34,12 @@ func (c *criService) ListPodSandboxStats(
podSandboxStats := new(runtime.ListPodSandboxStatsResponse)
for _, sandbox := range sandboxes {
metrics, err := metricsForSandbox(sandbox)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed to obtain metrics for sandbox %q: %w", sandbox.ID, err)
}

sandboxStats, err := c.podSandboxStats(ctx, sandbox, metrics)
if err != nil { //nolint:staticcheck // Ignore SA4023 as some platforms always return nil (unimplemented metrics)
if err != nil {
return nil, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err)
}
podSandboxStats.Stats = append(podSandboxStats.Stats, sandboxStats)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/server/service.go
Expand Up @@ -113,7 +113,7 @@ type criService struct {
baseOCISpecs map[string]*oci.Spec
// allCaps is the list of the capabilities.
// When nil, parsed from CapEff of /proc/self/status.
allCaps []string //nolint:unused // Ignore on non-Linux
allCaps []string //nolint:nolintlint,unused // Ignore on non-Linux
// unpackDuplicationSuppressor is used to make sure that there is only
// one in-flight fetch request or unpack handler for a given descriptor's
// or chain ID.
Expand Down
3 changes: 1 addition & 2 deletions pkg/cri/store/container/metadata.go
Expand Up @@ -28,10 +28,9 @@ import (
// 2) Metadata is checkpointed as containerd container label.

// metadataVersion is current version of container metadata.
const metadataVersion = "v1" // nolint
const metadataVersion = "v1"

// versionedMetadata is the internal versioned container metadata.
// nolint
type versionedMetadata struct {
// Version indicates the version of the versioned container metadata.
Version string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cri/store/container/status.go
Expand Up @@ -61,10 +61,9 @@ import (
// DELETED

// statusVersion is current version of container status.
const statusVersion = "v1" // nolint
const statusVersion = "v1"

// versionedStatus is the internal used versioned container status.
// nolint
type versionedStatus struct {
// Version indicates the version of the versioned container status.
Version string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cri/store/sandbox/metadata.go
Expand Up @@ -29,10 +29,9 @@ import (
// 2) Metadata is checkpointed as containerd container label.

// metadataVersion is current version of sandbox metadata.
const metadataVersion = "v1" // nolint
const metadataVersion = "v1"

// versionedMetadata is the internal versioned sandbox metadata.
// nolint
type versionedMetadata struct {
// Version indicates the version of the versioned sandbox metadata.
Version string
Expand Down
2 changes: 1 addition & 1 deletion pkg/progress/escape.go
Expand Up @@ -19,6 +19,6 @@ package progress
const (
escape = "\x1b"
reset = escape + "[0m"
red = escape + "[31m" //nolint:deadcode,unused,varcheck
red = escape + "[31m" //nolint:deadcode,nolintlint,unused,varcheck
green = escape + "[32m"
)

0 comments on commit 41b3cd2

Please sign in to comment.