migrate nolint coments to golangci-lint

This commit is contained in:
Antonio Ojea 2021-11-16 16:57:58 +01:00
parent 272b31da50
commit d126b14838
22 changed files with 41 additions and 34 deletions

View File

@ -53,7 +53,7 @@ type CPUManagerCheckpointV2 = CPUManagerCheckpoint
// NewCPUManagerCheckpoint returns an instance of Checkpoint // NewCPUManagerCheckpoint returns an instance of Checkpoint
func NewCPUManagerCheckpoint() *CPUManagerCheckpoint { func NewCPUManagerCheckpoint() *CPUManagerCheckpoint {
//lint:ignore unexported-type-in-api user-facing error message //nolint:staticcheck // unexported-type-in-api user-facing error message
return newCPUManagerCheckpointV2() return newCPUManagerCheckpointV2()
} }

View File

@ -54,7 +54,7 @@ func NewCheckpointState(stateDir, checkpointName, policyName string, initialCont
} }
if err := stateCheckpoint.restoreState(); err != nil { if err := stateCheckpoint.restoreState(); err != nil {
//lint:ignore ST1005 user-facing error message //nolint:staticcheck // ST1005 user-facing error message
return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the CPU manager checkpoint file %q before restarting Kubelet", return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the CPU manager checkpoint file %q before restarting Kubelet",
err, path.Join(stateDir, checkpointName)) err, path.Join(stateDir, checkpointName))
} }

View File

@ -35,7 +35,7 @@ type MemoryManagerCheckpoint struct {
// NewMemoryManagerCheckpoint returns an instance of Checkpoint // NewMemoryManagerCheckpoint returns an instance of Checkpoint
func NewMemoryManagerCheckpoint() *MemoryManagerCheckpoint { func NewMemoryManagerCheckpoint() *MemoryManagerCheckpoint {
//lint:ignore unexported-type-in-api user-facing error message //nolint:staticcheck // unexported-type-in-api user-facing error message
return &MemoryManagerCheckpoint{ return &MemoryManagerCheckpoint{
Entries: ContainerMemoryAssignments{}, Entries: ContainerMemoryAssignments{},
MachineState: NUMANodeMap{}, MachineState: NUMANodeMap{},

View File

@ -50,7 +50,7 @@ func NewCheckpointState(stateDir, checkpointName, policyName string) (State, err
} }
if err := stateCheckpoint.restoreState(); err != nil { if err := stateCheckpoint.restoreState(); err != nil {
//lint:ignore ST1005 user-facing error message //nolint:staticcheck // ST1005 user-facing error message
return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the memory manager checkpoint file %q before restarting Kubelet", return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the memory manager checkpoint file %q before restarting Kubelet",
err, path.Join(stateDir, checkpointName)) err, path.Join(stateDir, checkpointName))
} }

View File

@ -68,9 +68,8 @@ type criStatsProvider struct {
imageService internalapi.ImageManagerService imageService internalapi.ImageManagerService
// hostStatsProvider is used to get the status of the host filesystem consumed by pods. // hostStatsProvider is used to get the status of the host filesystem consumed by pods.
hostStatsProvider HostStatsProvider hostStatsProvider HostStatsProvider
//lint:ignore U1000 We can't import hcsshim due to Build constraints in hcsshim
// windowsNetworkStatsProvider is used by kubelet to gather networking stats on Windows // windowsNetworkStatsProvider is used by kubelet to gather networking stats on Windows
windowsNetworkStatsProvider interface{} windowsNetworkStatsProvider interface{} //nolint:unused // U1000 We can't import hcsshim due to Build constraints in hcsshim
// clock is used report current time // clock is used report current time
clock clock.Clock clock clock.Clock

View File

@ -18,6 +18,7 @@ package storage
import ( import (
"context" "context"
"k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
@ -96,7 +97,7 @@ func (r *REST) Categories() []string {
} }
func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) { func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
//lint:ignore SA1019 backwards compatibility //nolint:staticcheck // SA1019 backwards compatibility
//nolint: staticcheck //nolint: staticcheck
if options != nil && options.PropagationPolicy == nil && options.OrphanDependents == nil && if options != nil && options.PropagationPolicy == nil && options.OrphanDependents == nil &&
job.Strategy.DefaultGarbageCollectionPolicy(ctx) == rest.OrphanDependents { job.Strategy.DefaultGarbageCollectionPolicy(ctx) == rest.OrphanDependents {
@ -108,8 +109,7 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
} }
func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, deleteOptions *metav1.DeleteOptions, listOptions *internalversion.ListOptions) (runtime.Object, error) { func (r *REST) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, deleteOptions *metav1.DeleteOptions, listOptions *internalversion.ListOptions) (runtime.Object, error) {
//lint:ignore SA1019 backwards compatibility //nolint:staticcheck // SA1019 backwards compatibility
//nolint: staticcheck
if deleteOptions.PropagationPolicy == nil && deleteOptions.OrphanDependents == nil && if deleteOptions.PropagationPolicy == nil && deleteOptions.OrphanDependents == nil &&
job.Strategy.DefaultGarbageCollectionPolicy(ctx) == rest.OrphanDependents { job.Strategy.DefaultGarbageCollectionPolicy(ctx) == rest.OrphanDependents {
// Throw a warning if delete options are not explicitly set as Job deletion strategy by default is orphaning // Throw a warning if delete options are not explicitly set as Job deletion strategy by default is orphaning

View File

@ -23,33 +23,41 @@ import (
// This is an implementation of testing.testDeps. It doesn't need to do anything, because // This is an implementation of testing.testDeps. It doesn't need to do anything, because
// no tests are actually run. It does need a concrete implementation of at least ImportPath, // no tests are actually run. It does need a concrete implementation of at least ImportPath,
// which is called unconditionally when running tests. // which is called unconditionally when running tests.
//lint:ignore U1000 see comment above, we know it's unused normally. //nolint:unused // U1000 see comment above, we know it's unused normally.
type fakeTestDeps struct{} type fakeTestDeps struct{}
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) ImportPath() string { func (fakeTestDeps) ImportPath() string {
return "" return ""
} }
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) MatchString(pat, str string) (bool, error) { func (fakeTestDeps) MatchString(pat, str string) (bool, error) {
return false, nil return false, nil
} }
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) StartCPUProfile(io.Writer) error { func (fakeTestDeps) StartCPUProfile(io.Writer) error {
return nil return nil
} }
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) StopCPUProfile() {} func (fakeTestDeps) StopCPUProfile() {}
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) StartTestLog(io.Writer) {} func (fakeTestDeps) StartTestLog(io.Writer) {}
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) StopTestLog() error { func (fakeTestDeps) StopTestLog() error {
return nil return nil
} }
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) WriteHeapProfile(io.Writer) error { func (fakeTestDeps) WriteHeapProfile(io.Writer) error {
return nil return nil
} }
//nolint:unused // U1000 see comment above, we know it's unused normally.
func (fakeTestDeps) WriteProfileTo(string, io.Writer, int) error { func (fakeTestDeps) WriteProfileTo(string, io.Writer, int) error {
return nil return nil
} }

View File

@ -636,7 +636,7 @@ func BenchmarkDeepCopy(b *testing.B) {
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
//lint:ignore SA4010 the result of append is never used, it's acceptable since in benchmark testing. //nolint:staticcheck //iccheck // SA4010 the result of append is never used, it's acceptable since in benchmark testing.
instances = append(instances, runtime.DeepCopyJSON(obj)) instances = append(instances, runtime.DeepCopyJSON(obj))
} }
} }

View File

@ -25,7 +25,7 @@ import (
"testing" "testing"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
//lint:ignore SA1019 Keep using deprecated module; it still seems to be maintained and the api of the recommended replacement differs //nolint:staticcheck //iccheck // SA1019 Keep using deprecated module; it still seems to be maintained and the api of the recommended replacement differs
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"

View File

@ -148,7 +148,7 @@ func expectMatchDirect(t *testing.T, selector, ls Set) {
} }
} }
//lint:ignore U1000 currently commented out in TODO of TestSetMatches //nolint:staticcheck //iccheck // U1000 currently commented out in TODO of TestSetMatches
//nolint:unused,deadcode //nolint:unused,deadcode
func expectNoMatchDirect(t *testing.T, selector, ls Set) { func expectNoMatchDirect(t *testing.T, selector, ls Set) {
if SelectorFromSet(selector).Matches(ls) { if SelectorFromSet(selector).Matches(ls) {

View File

@ -132,14 +132,14 @@ func (r *jsonFrameReader) Read(data []byte) (int, error) {
// Return whatever remaining data exists from an in progress frame // Return whatever remaining data exists from an in progress frame
if n := len(r.remaining); n > 0 { if n := len(r.remaining); n > 0 {
if n <= len(data) { if n <= len(data) {
//lint:ignore SA4006,SA4010 underlying array of data is modified here. //nolint:staticcheck // SA4006,SA4010 underlying array of data is modified here.
data = append(data[0:0], r.remaining...) data = append(data[0:0], r.remaining...)
r.remaining = nil r.remaining = nil
return n, nil return n, nil
} }
n = len(data) n = len(data)
//lint:ignore SA4006,SA4010 underlying array of data is modified here. //nolint:staticcheck // SA4006,SA4010 underlying array of data is modified here.
data = append(data[0:0], r.remaining[:n]...) data = append(data[0:0], r.remaining[:n]...)
r.remaining = r.remaining[n:] r.remaining = r.remaining[n:]
return n, io.ErrShortBuffer return n, io.ErrShortBuffer
@ -157,7 +157,7 @@ func (r *jsonFrameReader) Read(data []byte) (int, error) {
// and set m to it, which means we need to copy the partial result back into data and preserve // and set m to it, which means we need to copy the partial result back into data and preserve
// the remaining result for subsequent reads. // the remaining result for subsequent reads.
if len(m) > n { if len(m) > n {
//lint:ignore SA4006,SA4010 underlying array of data is modified here. //nolint:staticcheck // SA4006,SA4010 underlying array of data is modified here.
data = append(data[0:0], m[:n]...) data = append(data[0:0], m[:n]...)
r.remaining = m[n:] r.remaining = m[n:]
return n, io.ErrShortBuffer return n, io.ErrShortBuffer

View File

@ -183,10 +183,10 @@ func (s *SpdyRoundTripper) dial(req *http.Request) (net.Conn, error) {
return nil, err return nil, err
} }
//lint:ignore SA1019 ignore deprecated httputil.NewProxyClientConn //nolint:staticcheck // SA1019 ignore deprecated httputil.NewProxyClientConn
proxyClientConn := httputil.NewProxyClientConn(proxyDialConn, nil) proxyClientConn := httputil.NewProxyClientConn(proxyDialConn, nil)
_, err = proxyClientConn.Do(&proxyReq) _, err = proxyClientConn.Do(&proxyReq)
//lint:ignore SA1019 ignore deprecated httputil.ErrPersistEOF: it might be //nolint:staticcheck // SA1019 ignore deprecated httputil.ErrPersistEOF: it might be
// returned from the invocation of proxyClientConn.Do // returned from the invocation of proxyClientConn.Do
if err != nil && err != httputil.ErrPersistEOF { if err != nil && err != httputil.ErrPersistEOF {
return nil, err return nil, err

View File

@ -143,7 +143,7 @@ func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope *RequestSc
// that will break existing clients. // that will break existing clients.
// Other cases where resource is not instantly deleted are: namespace deletion // Other cases where resource is not instantly deleted are: namespace deletion
// and pod graceful deletion. // and pod graceful deletion.
//lint:ignore SA1019 backwards compatibility //nolint:staticcheck // SA1019 backwards compatibility
//nolint: staticcheck //nolint: staticcheck
if !wasDeleted && options.OrphanDependents != nil && !*options.OrphanDependents { if !wasDeleted && options.OrphanDependents != nil && !*options.OrphanDependents {
status = http.StatusAccepted status = http.StatusAccepted

View File

@ -55,7 +55,7 @@ type fakeObjectConvertor struct {
apiVersion fieldpath.APIVersion apiVersion fieldpath.APIVersion
} }
//lint:ignore SA4009 backwards compatibility //nolint:staticcheck // SA4009 backwards compatibility
func (c *fakeObjectConvertor) Convert(in, out, context interface{}) error { func (c *fakeObjectConvertor) Convert(in, out, context interface{}) error {
if typedValue, ok := in.(*typed.TypedValue); ok { if typedValue, ok := in.(*typed.TypedValue); ok {
var err error var err error

View File

@ -83,7 +83,7 @@ func TestForbidden(t *testing.T) {
if result != test.expected { if result != test.expected {
t.Errorf("Forbidden response body(%#v...)\n expected: %v\ngot: %v", test.attributes, test.expected, result) t.Errorf("Forbidden response body(%#v...)\n expected: %v\ngot: %v", test.attributes, test.expected, result)
} }
//lint:ignore SA1019 backwards compatibility //nolint:staticcheck // SA1019 backwards compatibility
resultType := observer.HeaderMap.Get("Content-Type") resultType := observer.HeaderMap.Get("Content-Type")
if resultType != test.contentType { if resultType != test.contentType {
t.Errorf("Forbidden content type(%#v...) != %#v, got %#v", test.attributes, test.expected, result) t.Errorf("Forbidden content type(%#v...) != %#v, got %#v", test.attributes, test.expected, result)

View File

@ -120,7 +120,7 @@ func GetOriginal(w http.ResponseWriter) http.ResponseWriter {
return GetOriginal(inner) return GetOriginal(inner)
} }
//lint:ignore SA1019 backward compatibility //nolint:staticcheck // SA1019
var _ http.CloseNotifier = outerWithCloseNotifyAndFlush{} var _ http.CloseNotifier = outerWithCloseNotifyAndFlush{}
var _ http.Flusher = outerWithCloseNotifyAndFlush{} var _ http.Flusher = outerWithCloseNotifyAndFlush{}
var _ http.ResponseWriter = outerWithCloseNotifyAndFlush{} var _ http.ResponseWriter = outerWithCloseNotifyAndFlush{}

View File

@ -61,7 +61,7 @@ func TestWithHTTP1(t *testing.T) {
// so each decorator is expected to tick the count by one for each method. // so each decorator is expected to tick the count by one for each method.
defer counterGot.assert(t, &counter{FlushInvoked: 3, CloseNotifyInvoked: 3, HijackInvoked: 3}) defer counterGot.assert(t, &counter{FlushInvoked: 3, CloseNotifyInvoked: 3, HijackInvoked: 3})
//lint:ignore SA1019 backward compatibility //nolint:staticcheck // SA1019
w.(http.CloseNotifier).CloseNotify() w.(http.CloseNotifier).CloseNotify()
w.(http.Flusher).Flush() w.(http.Flusher).Flush()
@ -116,7 +116,7 @@ func TestWithHTTP2(t *testing.T) {
// so each decorator is expected to tick the count by one for each method. // so each decorator is expected to tick the count by one for each method.
defer counterGot.assert(t, &counter{FlushInvoked: 3, CloseNotifyInvoked: 3, HijackInvoked: 0}) defer counterGot.assert(t, &counter{FlushInvoked: 3, CloseNotifyInvoked: 3, HijackInvoked: 0})
//lint:ignore SA1019 backward compatibility //nolint:staticcheck // SA1019
w.(http.CloseNotifier).CloseNotify() w.(http.CloseNotifier).CloseNotify()
w.(http.Flusher).Flush() w.(http.Flusher).Flush()
@ -242,7 +242,7 @@ func assertCloseNotifierFlusherHijacker(t *testing.T, hijackableExpected bool, w
t.Errorf("Expected the http.ResponseWriter object to implement http.Flusher") t.Errorf("Expected the http.ResponseWriter object to implement http.Flusher")
} }
//lint:ignore SA1019 backward compatibility //nolint:staticcheck // SA1019
if _, ok := w.(http.CloseNotifier); !ok { if _, ok := w.(http.CloseNotifier); !ok {
t.Errorf("Expected the http.ResponseWriter object to implement http.CloseNotifier") t.Errorf("Expected the http.ResponseWriter object to implement http.CloseNotifier")
} }
@ -293,6 +293,6 @@ func (fw *fakeResponseWriterDecorator) CloseNotify() <-chan bool {
if fw.counter != nil { if fw.counter != nil {
fw.counter.CloseNotifyInvoked++ fw.counter.CloseNotifyInvoked++
} }
//lint:ignore SA1019 backward compatibility //nolint:staticcheck // SA1019
return fw.ResponseWriter.(http.CloseNotifier).CloseNotify() return fw.ResponseWriter.(http.CloseNotifier).CloseNotify()
} }

View File

@ -753,9 +753,9 @@ func shouldOrphanDependents(ctx context.Context, e *Store, accessor metav1.Objec
} }
// An explicit policy was set at deletion time, that overrides everything // An explicit policy was set at deletion time, that overrides everything
//lint:ignore SA1019 backwards compatibility //nolint:staticcheck // SA1019 backwards compatibility
if options != nil && options.OrphanDependents != nil { if options != nil && options.OrphanDependents != nil {
//lint:ignore SA1019 backwards compatibility //nolint:staticcheck // SA1019 backwards compatibility
return *options.OrphanDependents return *options.OrphanDependents
} }
if options != nil && options.PropagationPolicy != nil { if options != nil && options.PropagationPolicy != nil {
@ -796,7 +796,7 @@ func shouldDeleteDependents(ctx context.Context, e *Store, accessor metav1.Objec
} }
// If an explicit policy was set at deletion time, that overrides both // If an explicit policy was set at deletion time, that overrides both
//lint:ignore SA1019 backwards compatibility //nolint:staticcheck // SA1019 backwards compatibility
if options != nil && options.OrphanDependents != nil { if options != nil && options.OrphanDependents != nil {
return false return false
} }

View File

@ -27,7 +27,7 @@ import (
"sync" "sync"
"time" "time"
//lint:ignore SA1019 Keep using module since it's still being maintained and the api of google.golang.org/protobuf/proto differs //nolint:staticcheck // SA1019 Keep using module since it's still being maintained and the api of google.golang.org/protobuf/proto differs
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
openapi_v2 "github.com/googleapis/gnostic/openapiv2" openapi_v2 "github.com/googleapis/gnostic/openapiv2"

View File

@ -44,9 +44,9 @@ var (
) )
func init() { func init() {
//lint:ignore SA1019 - replacement function still calls prometheus.NewProcessCollector(). //nolint:staticcheck // SA1019 - replacement function still calls prometheus.NewProcessCollector().
RawMustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{})) RawMustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
//lint:ignore SA1019 - replacement function still calls prometheus.NewGoCollector(). //nolint:staticcheck // SA1019 - replacement function still calls prometheus.NewGoCollector().
RawMustRegister(prometheus.NewGoCollector()) RawMustRegister(prometheus.NewGoCollector())
} }

View File

@ -66,7 +66,7 @@ func NewBaseHandler(c *componentbaseconfig.DebuggingConfiguration, healthzHandle
routes.DebugFlags{}.Install(mux, "v", routes.StringFlagPutHandler(logs.GlogSetter)) routes.DebugFlags{}.Install(mux, "v", routes.StringFlagPutHandler(logs.GlogSetter))
} }
configz.InstallHandler(mux) configz.InstallHandler(mux)
//lint:ignore SA1019 See the Metrics Stability Migration KEP //nolint:staticcheck // SA1019 See the Metrics Stability Migration KEP
mux.Handle("/metrics", legacyregistry.Handler()) mux.Handle("/metrics", legacyregistry.Handler())
return mux return mux

View File

@ -38,7 +38,7 @@ import (
// leakedConnection is a global variable that should leak the active // leakedConnection is a global variable that should leak the active
// connection assigned here. // connection assigned here.
//lint:ignore U1000 intentional unused variable //nolint:unused // U1000 intentional unused variable
var leakedConnection *net.TCPConn var leakedConnection *net.TCPConn
// CloseWaitServerOptions holds server JSON options. // CloseWaitServerOptions holds server JSON options.