1608 msformat5529 mscheck 24991total 2351errors 11766warnings 10874notes

Showing 1000 of 24991 detailed findings. The summary includes all 24991 findings.

pkg/kubeapiserver/authorizer/reload.go1

280:20add-constantstring literal "reloading authorization config" appears more than twice; define a constant

pkg/kubeapiserver/authorizer/reload.go:280:20

279 if err != nil {
280 klog.ErrorS(err, "reloading authorization config")
281 metrics.RecordAuthorizationConfigAutomaticReloadFailure(r.apiServerID)

pkg/registry/core/service/allocator/storage/storage.go1

33:2blank-importsblank import should be justified by a comment

pkg/registry/core/service/allocator/storage/storage.go:33:2

32 api "k8s.io/kubernetes/pkg/apis/core"
33 _ "k8s.io/kubernetes/pkg/apis/core/install"
34 "k8s.io/kubernetes/pkg/registry/core/rangeallocation"

pkg/proxy/winkernel/proxier_test.go1

1425:6boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/proxy/winkernel/proxier_test.go:1425:6

1424 }
1425 if svcInfo.localTrafficDSR != true {
1426 t.Errorf("Failed to create DSR loadbalancer with local traffic policy")

pkg/kubeapiserver/authenticator/config.go1

107:22cognitive-complexityfunction has cognitive complexity 27; maximum is 7

pkg/kubeapiserver/authenticator/config.go:107:22

106// Kubernetes authentication mechanisms.
107func (config Config) New(serverLifecycle context.Context) (authenticator.Request, func(context.Context, *apiserver.AuthenticationConfiguration) error, *spec.SecurityDefinitions, spec3.SecuritySchemes, error) {
108 var authenticators []authenticator.Request

pkg/proxy/config/config.go1

473:6confusing-namingname newNodeTopologyConfig differs from NewNodeTopologyConfig only by capitalization

pkg/proxy/config/config.go:473:6

472// event handler completes processing and is only used for testing.
473func newNodeTopologyConfig(ctx context.Context, nodeInformer v1informers.NodeInformer, resyncPeriod time.Duration, callback func()) *NodeTopologyConfig {
474 result := &NodeTopologyConfig{

pkg/proxy/iptables/proxier_test.go1

5498:89confusing-resultsadjacent unnamed results of the same type should be named

pkg/proxy/iptables/proxier_test.go:5498:89

5497
5498func countEndpointsAndComments(iptablesData string, matchEndpoint string) (string, int, int) {
5499 var numEndpoints, numComments int

pkg/proxy/healthcheck/service_health.go1

297:6constructor-interface-returnNewFakeServiceHealthServer returns interface ServiceHealthServer although its concrete result is consistently FakeServiceHealthServer; return the concrete type

pkg/proxy/healthcheck/service_health.go:297:6

296// NewFakeServiceHealthServer allocates a new fake service healthcheck server manager
297func NewFakeServiceHealthServer() ServiceHealthServer {
298 return FakeServiceHealthServer{}

pkg/registry/core/node/strategy.go1

247:124context-as-argumentcontext.Context should be the first parameter

pkg/registry/core/node/strategy.go:247:124

246// ResourceLocation returns a URL and transport which one can use to send traffic for the specified node.
247func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGetter, proxyTransport http.RoundTripper, ctx context.Context, id string) (*url.URL, http.RoundTripper, error) {
248 schemeReq, name, portReq, valid := utilnet.SplitSchemeNamePort(id)

pkg/scheduler/backend/queue/scheduling_queue_test.go1

2403:6context-cancel-in-loopcancellation deferred inside a loop runs only when the surrounding function returns; cancel before the iteration ends

pkg/scheduler/backend/queue/scheduling_queue_test.go:2403:6

2402 ctx, cancel := context.WithCancel(ctx)
2403 defer cancel()
2404 q := NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c), WithQueueingHintMapPerProfile(m))

pkg/kubeapiserver/authenticator/config.go2

307:2context-stored-in-structdo not store context.Context in a struct; pass it explicitly to each operation

pkg/kubeapiserver/authenticator/config.go:307:2

306type authenticationConfigUpdater struct {
307 serverLifecycle context.Context
308 config Config
107:22cyclomatic-complexityfunction complexity is 23; maximum is 10

pkg/kubeapiserver/authenticator/config.go:107:22

106// Kubernetes authentication mechanisms.
107func (config Config) New(serverLifecycle context.Context) (authenticator.Request, func(context.Context, *apiserver.AuthenticationConfiguration) error, *spec.SecurityDefinitions, spec3.SecuritySchemes, error) {
108 var authenticators []authenticator.Request

pkg/scheduler/framework/plugins/volumebinding/binder_test.go1

196:4deep-exitprocess-exit calls should be confined to main or init

pkg/scheduler/framework/plugins/volumebinding/binder_test.go:196:4

195 logger.Error(nil, "Error syncing informer", "informer", v)
196 os.Exit(1)
197 }

pkg/proxy/config/api_test.go1

210:9deprecated-api-usagek8s.io/apimachinery/pkg/util/wait.PollImmediate is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release.

pkg/proxy/config/api_test.go:210:9

209
210 err := wait.PollImmediate(time.Millisecond*10, wait.ForeverTestTimeout, func() (bool, error) {
211 svcHandler.lock.Lock()

pkg/kubeapiserver/options/admission.go1

83:2discarded-error-resulterror result returned by fs.MarkDeprecated is discarded

pkg/kubeapiserver/options/admission.go:83:2

82 "Comma-delimited list of: "+strings.Join(a.GenericAdmission.Plugins.Registered(), ", ")+".")
83 fs.MarkDeprecated("admission-control", "Use --enable-admission-plugins or --disable-admission-plugins instead. Will be removed in a future version.")
84 fs.Lookup("admission-control").Hidden = false

pkg/kubeapiserver/admission/config.go1

23:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/admission/config.go:23:1

22
23// Config holds the configuration needed to for initialize the admission plugins
24type Config struct{}

pkg/proxy/conntrack/cleanup.go1

53:3early-returninvert the condition and return early to reduce nesting

pkg/proxy/conntrack/cleanup.go:53:3

52 if err != nil {
53 if errors.Is(err, unix.EINTR) {
54 klog.V(2).ErrorS(err, "received a partial result, continuing to clean with partial result")

pkg/proxy/conntrack/cleanup_test.go1

270:99empty-conditional-blockempty block should be removed or documented

pkg/proxy/conntrack/cleanup_test.go:270:99

269 entriesBeforeCleanup = append(entriesBeforeCleanup, entry)
270 if proto == unix.IPPROTO_UDP && port == testServicePort && dnatDest != testServingEndpointIP {
271 // we do not expect UDP entries with destination port `testServicePort` and DNATed destination

pkg/proxy/ipvs/ipset/ipset.go1

33:5error-namingpackage error variable should be named errFoo or ErrFoo

pkg/proxy/ipvs/ipset/ipset.go:33:5

32
33var validationError = fmt.Errorf("failed to validate entry for ipset")
34

pkg/kubeapiserver/options/admission_test.go1

33:12error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/admission_test.go:33:12

32 if len(options.Validate()) == 0 {
33 t.Errorf("Expect error, but got none")
34 }

pkg/registry/core/service/ipallocator/interfaces.go1

51:6error-type-namingerror implementation type should have an Error suffix

pkg/registry/core/service/ipallocator/interfaces.go:51:6

50
51type ErrNotInRange struct {
52 IP net.IP

pkg/registry/core/service/ipallocator/storage/storage_test.go1

82:2excessive-blank-identifiersassignment discards three or more results; name meaningful results or simplify the return contract

pkg/registry/core/service/ipallocator/storage/storage_test.go:82:2

81func TestEmpty(t *testing.T) {
82 _, storage, _, _, destroyFunc := newStorage(t)
83 defer destroyFunc()

pkg/kubeapiserver/admission/exclusion/resources.go1

58:6exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/admission/exclusion/resources.go:58:6

57// should intercept.
58func Included() []schema.GroupResource {
59 return slices.Clone(included)

pkg/kubeapiserver/options/authentication.go1

1:1file-length-limitfile has 914 lines; maximum is 500

pkg/kubeapiserver/options/authentication.go:1:1

1/*
2Copyright 2016 The Kubernetes Authors.

pkg/proxy/apis/config/fuzzer/fuzzer.go1

33:23flag-parameterboolean parameter is6 controls function flow

pkg/proxy/apis/config/fuzzer/fuzzer.go:33:23

32// generateRandomIP is copied from pkg/apis/networking/fuzzer/fuzzer.go
33func generateRandomIP(is6 bool, c randfill.Continue) string {
34 n := 4

pkg/kubeapiserver/admission/config.go1

1:1formatfile is not formatted

pkg/kubeapiserver/admission/config.go:1:1

1/*
2Copyright 2018 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/admission/config.go`

pkg/kubeapiserver/authenticator/config.go2

107:22function-lengthfunction has 61 statements and 143 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/authenticator/config.go:107:22

106// Kubernetes authentication mechanisms.
107func (config Config) New(serverLifecycle context.Context) (authenticator.Request, func(context.Context, *apiserver.AuthenticationConfiguration) error, *spec.SecurityDefinitions, spec3.SecuritySchemes, error) {
108 var authenticators []authenticator.Request
107:22function-result-limitfunction returns 5 values; maximum is 3

pkg/kubeapiserver/authenticator/config.go:107:22

106// Kubernetes authentication mechanisms.
107func (config Config) New(serverLifecycle context.Context) (authenticator.Request, func(context.Context, *apiserver.AuthenticationConfiguration) error, *spec.SecurityDefinitions, spec3.SecuritySchemes, error) {
108 var authenticators []authenticator.Request

pkg/proxy/util/nodeport_addresses.go1

111:4identical-switch-branchesswitch repeats a case body

pkg/proxy/util/nodeport_addresses.go:111:4

110 ip = v.IP
111 case *net.IPNet:
112 ip = v.IP

pkg/registry/core/node/storage/storage.go1

32:2import-alias-namingimport alias should contain lower-case letters and digits

pkg/registry/core/node/storage/storage.go:32:2

31 api "k8s.io/kubernetes/pkg/apis/core"
32 k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
33 "k8s.io/kubernetes/pkg/kubelet/client"

pkg/kubeapiserver/authenticator/config.go1

238:2import-shadowingidentifier authenticator shadows an imported package

pkg/kubeapiserver/authenticator/config.go:238:2

237
238 authenticator := union.New(authenticators...)
239

pkg/registry/apps/replicaset/storage/storage_test.go1

122:4increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/apps/replicaset/storage/storage_test.go:122:4

121 object := obj.(*apps.ReplicaSet)
122 object.Spec.Replicas = object.Spec.Replicas + 1
123 return object

pkg/proxy/endpointslicecache.go1

108:3inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/endpointslicecache.go:108:3

107 if _, ok := cache.trackerByServiceMap[serviceKey]; !ok {
108 cache.trackerByServiceMap[serviceKey] = newEndpointSliceTracker()
109 }

pkg/proxy/iptables/number_generated_rules_test.go1

374:21inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/proxy/iptables/number_generated_rules_test.go:374:21

373 Ports: []discovery.EndpointPort{{
374 Name: ptr.To(fmt.Sprintf("%d", epPort)),
375 Port: ptr.To(int32(epPort)),

pkg/kubeapiserver/options/authentication_test.go1

85:24insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:85:24

84 testSA: &ServiceAccountAuthenticationOptions{
85 Issuers: []string{"http://foo.bar.com"},
86 KeyFiles: []string{"testkeyfile1", "testkeyfile2"},

pkg/proxy/ipvs/util/ipvs.go1

29:16interface-method-limitinterface has 11 methods, exceeding the configured design limit of 10

pkg/proxy/ipvs/util/ipvs.go:29:16

28// Interface is an injectable interface for running ipvs commands. Implementations must be goroutine-safe.
29type Interface interface {
30 // Flush clears all virtual servers in system. return occurred error immediately.

pkg/proxy/ipvs/proxier.go1

1105:7max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/proxy/ipvs/proxier.go:1105:7

1104 for _, entry := range entries {
1105 if valid := nodePortLocalSet.validateEntry(entry); !valid {
1106 proxier.logger.Error(nil, "Error adding entry to ipset", "entry", entry, "ipset", nodePortLocalSet.Name)

pkg/kubeapiserver/options/authentication.go2

670:40max-parametersfunction has 9 parameters; maximum is 8

pkg/kubeapiserver/options/authentication.go:670:40

669// The input context controls the lifecycle of background goroutines started to reload the authentication config file.
670func (o *BuiltInAuthenticationOptions) ApplyTo(
671 ctx context.Context,
148:6max-public-structsfile declares more than 5 exported structs

pkg/kubeapiserver/options/authentication.go:148:6

147// TokenFileAuthenticationOptions contains token file authentication options for API Server
148type TokenFileAuthenticationOptions struct {
149 TokenFile string

pkg/kubeapiserver/options/admission.go1

84:2modifies-parameterassignment modifies parameter fs

pkg/kubeapiserver/options/admission.go:84:2

83 fs.MarkDeprecated("admission-control", "Use --enable-admission-plugins or --disable-admission-plugins instead. Will be removed in a future version.")
84 fs.Lookup("admission-control").Hidden = false
85

pkg/proxy/endpointschangetracker.go1

246:3modifies-value-receiverassignment modifies value receiver em

pkg/proxy/endpointschangetracker.go:246:3

245 }
246 em[svcPortName] = epList
247 }

pkg/kubeapiserver/authorizer/modes/modes_test.go1

22:16nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/authorizer/modes/modes_test.go:22:16

21func TestIsValidAuthorizationMode(t *testing.T) {
22 var tests = []struct {
23 authzMode string

pkg/proxy/ipvs/netlink_linux.go1

57:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/proxy/ipvs/netlink_linux.go:57:4

56 if err == unix.EEXIST {
57 return true, nil
58 }

pkg/kubeapiserver/options/authorization.go1

210:3nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/kubeapiserver/options/authorization.go:210:3

209 if o == nil {
210 return nil, nil
211 }

pkg/registry/admissionregistration/mutatingadmissionpolicybinding/storage/storage_test.go1

61:3no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/registry/admissionregistration/mutatingadmissionpolicybinding/storage/storage_test.go:61:3

60 storage, server := newInsecureStorage(t)
61 defer server.Terminate(t)
62 defer storage.Store.DestroyFunc()

pkg/kubeapiserver/options/authentication_test.go1

1786:4no-else-after-returnremove else and unindent its body after the return

pkg/kubeapiserver/options/authentication_test.go:1786:4

1785 return "The system cannot find the file specified"
1786 } else {
1787 return "no such file or directory"

pkg/kubeapiserver/options/authentication.go1

876:6no-initreplace init with explicit initialization

pkg/kubeapiserver/options/authentication.go:876:6

875
876func init() {
877 install.Install(cfgScheme)

pkg/proxy/iptables/cleanup.go1

38:2no-naked-returnreturn values must be explicit

pkg/proxy/iptables/cleanup.go:38:2

37 }
38 return
39}

pkg/kubeapiserver/admission/exclusion/resources.go1

30:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/admission/exclusion/resources.go:30:5

29// in either include or excluded list.
30var included = []schema.GroupResource{
31 {Group: "", Resource: "bindings"},

pkg/kubeapiserver/authenticator/config.go1

148:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/authenticator/config.go:148:5

147 }
148 if len(config.ServiceAccountIssuers) > 0 && config.ServiceAccountPublicKeysGetter != nil {
149 serviceAccountAuth, err := newServiceAccountAuthenticator(config.ServiceAccountIssuers, config.ServiceAccountPublicKeysGetter, config.APIAudiences, config.ServiceAccountTokenGetter)

pkg/registry/networking/ipaddress/strategy.go1

66:2overwritten-before-usethis value of newIPAddress is overwritten before use

pkg/registry/networking/ipaddress/strategy.go:66:2

65func (ipAddressStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
66 newIPAddress := obj.(*networking.IPAddress)
67 oldIPAddress := old.(*networking.IPAddress)

pkg/kubeapiserver/admission/config.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/admission/config.go:17:9

16
17package admission
18

pkg/proxy/ipvs/util/doc.go1

19:9package-directory-mismatchpackage ipvs does not match directory util

pkg/proxy/ipvs/util/doc.go:19:9

18
19package ipvs
20

pkg/registry/core/node/storage/storage_test.go1

259:16possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/registry/core/node/storage/storage_test.go:259:16

258
259 if location.Host != testCase.host {
260 t.Errorf("Unexpected host: expected %v, but got %v", testCase.host, location.Host)

pkg/proxy/conntrack/cleanup_test.go1

295:13range-value-addresstaking the address of range value ip can be misleading

pkg/proxy/conntrack/cleanup_test.go:295:13

294 for _, port := range []uint16{testServicePort, testNonServicePort} {
295 entry := &netlink.ConntrackFlow{
296 FamilyType: unix.AF_INET,

pkg/proxy/winkernel/proxier.go1

507:7receiver-namingreceiver name ep is inconsistent with info

pkg/proxy/winkernel/proxier.go:507:7

506
507func (ep *endpointInfo) DecrementRefCount() {
508 klog.V(3).InfoS("Decrementing Endpoint RefCount", "endpointInfo", ep)

pkg/proxy/conntrack/sysctls.go1

45:30redefines-builtin-ididentifier max shadows a predeclared identifier

pkg/proxy/conntrack/sysctls.go:45:30

44 // SetMax adjusts nf_conntrack_max.
45 SetMax(ctx context.Context, max int) error
46 // SetTCPEstablishedTimeout adjusts nf_conntrack_tcp_timeout_established.

pkg/kubeapiserver/options/authentication_test.go1

1286:20redundant-conversionconversion from syscall.Errno to the identical type is redundant

pkg/kubeapiserver/options/authentication_test.go:1286:20

1285 file: func() string { return "bogus-missing-file" },
1286 expectErr: syscall.Errno(syscall.ENOENT).Error(),
1287 expectedConfig: nil,

pkg/registry/batch/job/storage/storage_test.go1

186:2redundant-final-returnomit the unnecessary return at the end of a resultless function

pkg/registry/batch/job/storage/storage_test.go:186:2

185 r.text = text
186 return
187}

pkg/proxy/config/api_test.go1

24:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/config/api_test.go:24:2

23
24 v1 "k8s.io/api/core/v1"
25 discoveryv1 "k8s.io/api/discovery/v1"

pkg/kubeapiserver/authorizer/config.go1

103:3single-case-switchswitch with one case can be replaced by an if statement

pkg/kubeapiserver/authorizer/config.go:103:3

102 // Keep cases in sync with constant list in k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes/modes.go.
103 switch configuredAuthorizer.Type {
104 case authzconfig.AuthorizerType(modes.ModeNode):

pkg/kubeapiserver/authenticator/config.go1

265:6slice-preallocationpreallocate jwtAuthenticators with capacity len(range source) before appending once per iteration

pkg/kubeapiserver/authenticator/config.go:265:6

264 }()
265 var jwtAuthenticators []authenticator.Token
266 var healthChecks []func() error

pkg/proxy/healthcheck/healthcheck_test.go1

396:31standard-http-method-constantreplace the HTTP method literal with http.MethodGet

pkg/proxy/healthcheck/healthcheck_test.go:396:31

395
396 req, err := http.NewRequest("GET", "/healthz", nil)
397 if err != nil {

pkg/kubeapiserver/admission/initializer.go1

29:1task-commentTODO comment should be resolved or linked to an owned work item

pkg/kubeapiserver/admission/initializer.go:29:1

28
29// TODO add a `WantsToRun` which takes a stopCh. Might make it generic.
30

pkg/kubeapiserver/authorizer/modes/modes_test.go1

21:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/authorizer/modes/modes_test.go:21:6

20
21func TestIsValidAuthorizationMode(t *testing.T) {
22 var tests = []struct {

pkg/scheduler/backend/queue/backoff_queue_test.go1

108:45time-value-equalitycompare time.Time values with Time.Equal instead of == or !=

pkg/scheduler/backend/queue/backoff_queue_test.go:108:45

107 bq := newBackoffQueue(clock.RealClock{}, tt.initialBackoffDuration, tt.maxBackoffDuration, convertLessFn(newDefaultQueueSort()), true)
108 if got := bq.getBackoffTime(tt.podInfo); got != tt.want {
109 t.Errorf("backoffQueue.getBackoffTime() = %v, want %v", got, tt.want)

pkg/kubeapiserver/admission/initializer.go1

36:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/admission/initializer.go:36:1

35
36var _ admission.PluginInitializer = &PluginInitializer{}
37

pkg/proxy/healthcheck/healthcheck_test.go1

153:13unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/healthcheck/healthcheck_test.go:153:13

152 hcsi := newServiceHealthServer("hostname", nil, listener, httpFactory, nodePortAddresses, proxyChecker, v1.IPv4Protocol)
153 hcs := hcsi.(*server)
154 if len(hcs.services) != 0 {

pkg/kubeapiserver/default_storage_factory_builder.go1

112:81unexported-returnexported function returns an unexported type

pkg/kubeapiserver/default_storage_factory_builder.go:112:81

111// This method mutates the receiver (StorageFactoryConfig). It must never mutate the inputs.
112func (c *StorageFactoryConfig) Complete(etcdOptions *serveroptions.EtcdOptions) *completedStorageFactoryConfig {
113 c.StorageConfig = etcdOptions.StorageConfig

pkg/registry/authentication/tokenreview/storage.go1

80:39unnecessary-formatformatting call has no formatting directive

pkg/registry/authentication/tokenreview/storage.go:80:39

79 if len(tokenReview.Spec.Token) == 0 {
80 return nil, apierrors.NewBadRequest(fmt.Sprintf("token is required for TokenReview in authentication"))
81 }

pkg/kubeapiserver/authorizer/reload.go1

248:50unused-parameterparameter ctx is unused

pkg/kubeapiserver/authorizer/reload.go:248:50

247
248func (r *reloadableAuthorizerResolver) checkFile(ctx context.Context) {
249 r.lastLoadedLock.Lock()

pkg/kubeapiserver/admission/config.go1

27:7unused-receiverreceiver c is unused

pkg/kubeapiserver/admission/config.go:27:7

26// New sets up the plugins and admission start hooks needed for admission
27func (c *Config) New() ([]admission.PluginInitializer, error) {
28 return []admission.PluginInitializer{NewPluginInitializer()}, nil

pkg/kubeapiserver/options/authentication.go1

624:23use-anyuse any instead of interface{}

pkg/kubeapiserver/options/authentication.go:624:23

623 case len(o.ServiceAccounts.KeyFiles) > 0:
624 allPublicKeys := []interface{}{}
625 for _, keyfile := range o.ServiceAccounts.KeyFiles {

pkg/kubeapiserver/authenticator/config.go1

382:15use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/authenticator/config.go:382:15

381 if publicKeysGetter == nil {
382 return nil, fmt.Errorf("no public key getter provided")
383 }

pkg/proxy/conntrack/cleanup_test.go1

336:2use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/conntrack/cleanup_test.go:336:2

335 // sort the actual flows before comparison
336 sort.Slice(actualEntries, func(i, j int) bool {
337 return actualEntries[i].String() < actualEntries[j].String()

pkg/registry/core/service/allocator/utils.go1

26:18var-declarationomit the explicit zero value from the variable declaration

pkg/registry/core/service/allocator/utils.go:26:18

25func countBits(n *big.Int) int {
26 var count int = 0
27 for _, w := range n.Bits() {

pkg/proxy/endpointschangetracker_test.go1

299:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:299:2

298 }
299 multipleSubsets_s1 := func(eps *discovery.EndpointSlice) {
300 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/default_storage_factory_builder.go1

84:63add-constantstring literal "v1beta1" appears more than twice; define a constant

pkg/kubeapiserver/default_storage_factory_builder.go:84:63

83 certificates.Resource("clustertrustbundles").WithVersion("v1beta1"), // TODO: remove in 1.38
84 certificates.Resource("podcertificaterequests").WithVersion("v1beta1"),
85 storagemigration.Resource("storageversionmigrations").WithVersion("v1beta1"),

pkg/registry/certificates/clustertrustbundle/strategy_test.go1

33:5boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/registry/certificates/clustertrustbundle/strategy_test.go:33:5

32func TestAllowCreateOnUpdate(t *testing.T) {
33 if Strategy.AllowCreateOnUpdate(context.Background()) != false {
34 t.Errorf("Got true, want false")

pkg/kubeapiserver/authenticator/config.go1

257:6cognitive-complexityfunction has cognitive complexity 12; maximum is 7

pkg/kubeapiserver/authenticator/config.go:257:6

256
257func newJWTAuthenticator(serverLifecycle context.Context, config *apiserver.AuthenticationConfiguration, oidcSigningAlgs []string, apiAudiences authenticator.Audiences, disallowedIssuers []string, egressLookup egressselector.Lookup, apiServerID string) (_ *jwtAuthenticatorWithCancel, buildErr error) {
258 ctx, cancel := context.WithCancel(serverLifecycle)

pkg/proxy/conntrack/sysctls.go1

58:6confusing-namingname setSysctls differs from SetSysctls only by capitalization

pkg/proxy/conntrack/sysctls.go:58:6

57
58func setSysctls(ctx context.Context, ct conntrackConfigurer, config *kubeproxyconfig.KubeProxyConntrackConfiguration) error {
59 max, err := getConntrackMax(ctx, config, detectNumCPU())

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

624:114confusing-resultsadjacent unnamed results of the same type should be named

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:624:114

623
624func mustMakeEd25519KeyAndProof(t *testing.T, toBeSigned []byte) (ed25519.PrivateKey, ed25519.PublicKey, []byte, []byte) {
625 pub, priv, err := ed25519.GenerateKey(rand.Reader)

pkg/proxy/ipvs/ipset/ipset.go1

280:6constructor-interface-returnNew returns interface Interface although its concrete result is consistently *runner; return the concrete type

pkg/proxy/ipvs/ipset/ipset.go:280:6

279// New returns a new Interface which will exec ipset.
280func New() Interface {
281 return &runner{

pkg/registry/core/pod/storage/eviction.go1

318:52context-as-argumentcontext.Context should be the first parameter

pkg/registry/core/pod/storage/eviction.go:318:52

317
318func addConditionAndDeletePod(r *EvictionREST, ctx context.Context, name string, validation rest.ValidateObjectFunc, options *metav1.DeleteOptions) error {
319 if !dryrun.IsDryRun(options.DryRun) {

pkg/registry/certificates/certificates/strategy_test.go1

36:3context-stored-in-structdo not store context.Context in a struct; pass it explicitly to each operation

pkg/registry/certificates/certificates/strategy_test.go:36:3

35 tests := map[string]struct {
36 ctx context.Context
37 obj runtime.Object

pkg/kubeapiserver/authorizer/config.go1

82:22cyclomatic-complexityfunction complexity is 11; maximum is 10

pkg/kubeapiserver/authorizer/config.go:82:22

81// Note: the cel compiler construction depends on feature gates and the compatibility version to be initialized.
82func (config Config) New(ctx context.Context, serverID string) (authorizer.Authorizer, authorizer.RuleResolver, error) {
83 if len(config.AuthorizationConfiguration.Authorizers) == 0 {

pkg/scheduler/framework/runtime/batch_test.go1

105:3deep-exitprocess-exit calls should be confined to main or init

pkg/scheduler/framework/runtime/batch_test.go:105:3

104 if err != nil {
105 log.Fatal("Couldn't register test.")
106 }

pkg/proxy/config/api_test.go1

222:8deprecated-api-usagek8s.io/apimachinery/pkg/util/wait.PollImmediate is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release.

pkg/proxy/config/api_test.go:222:8

221
222 err = wait.PollImmediate(time.Millisecond*10, wait.ForeverTestTimeout, func() (bool, error) {
223 epsHandler.lock.Lock()

pkg/kubeapiserver/options/authentication_test.go1

1633:3discarded-error-resulterror result returned by fmt.Println is discarded

pkg/kubeapiserver/options/authentication_test.go:1633:3

1632 if err != nil {
1633 fmt.Println("Error creating public key file:", err)
1634 return

pkg/kubeapiserver/admission/config.go1

26:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/admission/config.go:26:1

25
26// New sets up the plugins and admission start hooks needed for admission
27func (c *Config) New() ([]admission.PluginInitializer, error) {

pkg/proxy/ipvs/ipset/ipset.go1

345:2early-returninvert the condition and return early to reduce nesting

pkg/proxy/ipvs/ipset/ipset.go:345:2

344func (runner *runner) TestEntry(entry string, set string) (bool, error) {
345 if out, err := runner.exec.Command(IPSetCmd, "test", set, entry).CombinedOutput(); err == nil {
346 reg, e := regexp.Compile("is NOT in set " + set)

pkg/proxy/conntrack/cleanup_test.go1

281:70empty-conditional-blockempty block should be removed or documented

pkg/proxy/conntrack/cleanup_test.go:281:70

280 entriesBeforeCleanup = append(entriesBeforeCleanup, entry)
281 if proto == unix.IPPROTO_UDP && dnatDest != testServingEndpointIP {
282 // we do not expect UDP entries with DNATed destination address not

pkg/proxy/util/nfacct/nfacct_others.go1

26:5error-namingpackage error variable should be named errFoo or ErrFoo

pkg/proxy/util/nfacct/nfacct_others.go:26:5

25
26var unsupportedError = fmt.Errorf(runtime.GOOS + "/" + runtime.GOARCH + " is unsupported")
27

pkg/kubeapiserver/options/admission_test.go1

41:12error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/admission_test.go:41:12

40 if len(options.Validate()) == 0 {
41 t.Errorf("Expect error, but got none")
42 }

pkg/registry/core/service/portallocator/allocator.go1

47:6error-type-namingerror implementation type should have an Error suffix

pkg/registry/core/service/portallocator/allocator.go:47:6

46
47type ErrNotInRange struct {
48 ValidPorts string

pkg/registry/core/service/ipallocator/storage/storage_test.go1

90:2excessive-blank-identifiersassignment discards three or more results; name meaningful results or simplify the return contract

pkg/registry/core/service/ipallocator/storage/storage_test.go:90:2

89func TestErrors(t *testing.T) {
90 _, storage, _, _, destroyFunc := newStorage(t)
91 defer destroyFunc()

pkg/kubeapiserver/admission/exclusion/resources.go1

64:6exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/admission/exclusion/resources.go:64:6

63// should ignore.
64func Excluded() []schema.GroupResource {
65 return slices.Clone(excluded)

pkg/kubeapiserver/options/authentication_test.go1

1:1file-length-limitfile has 1790 lines; maximum is 500

pkg/kubeapiserver/options/authentication_test.go:1:1

1/*
2Copyright 2018 The Kubernetes Authors.

pkg/proxy/apis/config/fuzzer/fuzzer.go1

52:25flag-parameterboolean parameter is6 controls function flow

pkg/proxy/apis/config/fuzzer/fuzzer.go:52:25

51// generateRandomCIDR is copied from pkg/apis/networking/fuzzer/fuzzer.go
52func generateRandomCIDR(is6 bool, c randfill.Continue) string {
53 ip, err := netip.ParseAddr(generateRandomIP(is6, c))

pkg/kubeapiserver/admission/exclusion/resources.go1

1:1formatfile is not formatted

pkg/kubeapiserver/admission/exclusion/resources.go:1:1

1/*
2Copyright 2024 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/admission/exclusion/resources.go`

pkg/kubeapiserver/authorizer/config.go1

82:22function-lengthfunction has 31 statements and 81 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/authorizer/config.go:82:22

81// Note: the cel compiler construction depends on feature gates and the compatibility version to be initialized.
82func (config Config) New(ctx context.Context, serverID string) (authorizer.Authorizer, authorizer.RuleResolver, error) {
83 if len(config.AuthorizationConfiguration.Authorizers) == 0 {

pkg/kubeapiserver/authorizer/reload.go1

95:40function-result-limitfunction returns 4 values; maximum is 3

pkg/kubeapiserver/authorizer/reload.go:95:40

94
95func (r *reloadableAuthorizerResolver) RulesFor(ctx context.Context, user user.Info, namespace string) ([]authorizer.ResourceRuleInfo, []authorizer.NonResourceRuleInfo, bool, error) {
96 return r.current.Load().ruleResolver.RulesFor(ctx, user, namespace)

pkg/proxy/util/utils.go1

79:3identical-switch-branchesswitch repeats a case body

pkg/proxy/util/utils.go:79:3

78 ip = v.IP
79 case *net.IPNet:
80 ip = v.IP

pkg/kubeapiserver/authorizer/config.go1

147:2import-shadowingidentifier authorizer shadows an imported package

pkg/kubeapiserver/authorizer/config.go:147:2

146 // Construct the authorizers / ruleResolvers for the given configuration
147 authorizer, ruleResolver, err := r.newForConfig(r.initialConfig.AuthorizationConfiguration)
148 if err != nil {

pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage_test.go1

110:4increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage_test.go:110:4

109 object := obj.(*autoscaling.HorizontalPodAutoscaler)
110 object.Spec.MaxReplicas = object.Spec.MaxReplicas + 1
111 return object

pkg/proxy/endpointslicecache.go1

248:4inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/endpointslicecache.go:248:4

247 if _, exists := endpointSet[endpointInfo.String()]; !exists || !terminating {
248 endpointSet[endpointInfo.String()] = cache.makeEndpointInfo(endpointInfo, svcPortName)
249 }

pkg/proxy/iptables/number_generated_rules_test.go1

414:17inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/proxy/iptables/number_generated_rules_test.go:414:17

413 {
414 Name: fmt.Sprintf("%d", epPort),
415 Protocol: v1.ProtocolTCP,

pkg/kubeapiserver/options/authentication_test.go1

98:24insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:98:24

97 testSA: &ServiceAccountAuthenticationOptions{
98 Issuers: []string{"http://foo.bar.com"},
99 KeyFiles: []string{"testkeyfile1", "testkeyfile2"},

pkg/proxy/serviceport.go1

35:18interface-method-limitinterface has 16 methods, exceeding the configured design limit of 10

pkg/proxy/serviceport.go:35:18

34// ServicePort is an interface which abstracts information about a service.
35type ServicePort interface {
36 // String returns service string. An example format can be: `IP:Port/Protocol`.

pkg/proxy/ipvs/proxier.go1

1660:7max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/proxy/ipvs/proxier.go:1660:7

1659 err = proxier.ipvs.UpdateRealServer(appliedVirtualServer, newDest)
1660 if err != nil {
1661 proxier.logger.Error(err, "Failed to update destination", "newDest", newDest)

pkg/proxy/endpointslicecache_test.go1

512:6max-parametersfunction has 9 parameters; maximum is 8

pkg/proxy/endpointslicecache_test.go:512:6

511
512func generateEndpointSliceWithOffset(serviceName, namespace string, sliceNum, offset, numEndpoints, unreadyMod int, terminatingMod int, hosts []string, portNums []*int32) *discovery.EndpointSlice {
513 endpointSlice := &discovery.EndpointSlice{

pkg/kubeapiserver/options/authentication.go2

153:6max-public-structsfile declares more than 5 exported structs

pkg/kubeapiserver/options/authentication.go:153:6

152// WebHookAuthenticationOptions contains web hook authentication options for API Server
153type WebHookAuthenticationOptions struct {
154 ConfigFile string
704:2modifies-parameterassignment modifies parameter authInfo

pkg/kubeapiserver/options/authentication.go:704:2

703
704 authInfo.RequestHeaderConfig = authenticatorConfig.RequestHeaderConfig
705 authInfo.APIAudiences = o.APIAudiences

pkg/proxy/endpointslicecache.go1

329:2modifies-value-receiverassignment modifies value receiver e

pkg/proxy/endpointslicecache.go:329:2

328func (e byEndpoint) Swap(i, j int) {
329 e[i], e[j] = e[j], e[i]
330}

pkg/kubeapiserver/options/admission_test.go1

66:13nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/admission_test.go:66:13

65func TestComputeEnabledAdmission(t *testing.T) {
66 tests := []struct {
67 name string

pkg/proxy/ipvs/netlink_linux.go1

101:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/proxy/ipvs/netlink_linux.go:101:4

100 if ok {
101 return nil
102 }

pkg/proxy/healthcheck/healthcheck_test.go1

84:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/healthcheck/healthcheck_test.go:84:2

83 // Not implemented
84 return nil, nil
85}

pkg/registry/admissionregistration/mutatingadmissionpolicybinding/storage/storage_test.go1

62:3no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/registry/admissionregistration/mutatingadmissionpolicybinding/storage/storage_test.go:62:3

61 defer server.Terminate(t)
62 defer storage.Store.DestroyFunc()
63 t.Run(b.Name, func(t *testing.T) {

pkg/proxy/iptables/proxier_test.go1

727:6no-else-after-returnremove else and unindent its body after the return

pkg/proxy/iptables/proxier_test.go:727:6

726 return false
727 } else if chain.Rules[j].Comment != nil && strings.Contains(chain.Rules[j].Comment.Value, "must be the last rule") {
728 return true

pkg/proxy/apis/config/scheme/scheme.go1

35:6no-initreplace init with explicit initialization

pkg/proxy/apis/config/scheme/scheme.go:35:6

34
35func init() {
36 AddToScheme(Scheme)

pkg/proxy/iptables/proxier.go1

632:3no-naked-returnreturn values must be explicit

pkg/proxy/iptables/proxier.go:632:3

631 proxier.logger.V(2).Info("Not syncing iptables until Services and Endpoints have been received from master")
632 return
633 }

pkg/kubeapiserver/admission/exclusion/resources.go1

45:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/admission/exclusion/resources.go:45:5

44// The version is omitted, all versions of the same GroupResource are treated the same.
45var excluded = []schema.GroupResource{
46 // BEGIN interception of these non-persisted resources may break the cluster

pkg/kubeapiserver/options/authentication.go1

282:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:282:6

281 }
282 if len(o.ServiceAccounts.KeyFiles) == 0 && o.ServiceAccounts.ExternalPublicKeysGetter == nil {
283 allErrors = append(allErrors, errors.New("either `--service-account-key-file` or `--service-account-signing-endpoint` must be set"))

pkg/registry/networking/ipaddress/strategy.go1

67:2overwritten-before-usethis value of oldIPAddress is overwritten before use

pkg/registry/networking/ipaddress/strategy.go:67:2

66 newIPAddress := obj.(*networking.IPAddress)
67 oldIPAddress := old.(*networking.IPAddress)
68

pkg/kubeapiserver/admission/exclusion/resources.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/admission/exclusion/resources.go:17:9

16
17package exclusion
18

pkg/proxy/ipvs/util/ipvs.go1

19:9package-directory-mismatchpackage ipvs does not match directory util

pkg/proxy/ipvs/util/ipvs.go:19:9

18
19package ipvs
20

pkg/registry/core/node/storage/storage_test.go1

260:82possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/registry/core/node/storage/storage_test.go:260:82

259 if location.Host != testCase.host {
260 t.Errorf("Unexpected host: expected %v, but got %v", testCase.host, location.Host)
261 }

pkg/proxy/conntrack/cleanup_test.go1

295:13range-value-addresstaking the address of range value port can be misleading

pkg/proxy/conntrack/cleanup_test.go:295:13

294 for _, port := range []uint16{testServicePort, testNonServicePort} {
295 entry := &netlink.ConntrackFlow{
296 FamilyType: unix.AF_INET,

pkg/proxy/winkernel/proxier.go1

519:7receiver-namingreceiver name ep is inconsistent with info

pkg/proxy/winkernel/proxier.go:519:7

518
519func (ep *endpointInfo) Cleanup() {
520 klog.V(3).InfoS("Endpoint cleanup", "endpointInfo", ep)

pkg/proxy/conntrack/sysctls.go1

59:2redefines-builtin-ididentifier max shadows a predeclared identifier

pkg/proxy/conntrack/sysctls.go:59:2

58func setSysctls(ctx context.Context, ct conntrackConfigurer, config *kubeproxyconfig.KubeProxyConntrackConfiguration) error {
59 max, err := getConntrackMax(ctx, config, detectNumCPU())
60 if err != nil {

pkg/proxy/apis/config/v1alpha1/defaults.go1

89:11redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/apis/config/v1alpha1/defaults.go:89:11

88 if obj.IPTables.MasqueradeBit == nil {
89 temp := int32(14)
90 obj.IPTables.MasqueradeBit = &temp

pkg/proxy/config/config.go1

26:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/config/config.go:26:2

25
26 v1 "k8s.io/api/core/v1"
27 discoveryv1 "k8s.io/api/discovery/v1"

pkg/kubeapiserver/authorizer/reload.go1

119:3single-case-switchswitch with one case can be replaced by an if statement

pkg/kubeapiserver/authorizer/reload.go:119:3

118 // Keep cases in sync with constant list in k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes/modes.go.
119 switch configuredAuthorizer.Type {
120 case authzconfig.AuthorizerType(modes.ModeNode):

pkg/kubeapiserver/authenticator/config.go1

266:6slice-preallocationpreallocate healthChecks with capacity len(range source) before appending once per iteration

pkg/kubeapiserver/authenticator/config.go:266:6

265 var jwtAuthenticators []authenticator.Token
266 var healthChecks []func() error
267 for _, jwtAuthenticator := range config.JWT {

pkg/proxy/healthcheck/healthcheck_test.go1

897:30standard-http-method-constantreplace the HTTP method literal with http.MethodGet

pkg/proxy/healthcheck/healthcheck_test.go:897:30

896 handler := hsTest.server.(*fakeHTTPServer).handler
897 req, err := http.NewRequest("GET", string(hsTest.url), nil)
898 if err != nil {

pkg/kubeapiserver/authenticator/config.go1

268:3task-commentTODO comment should be resolved or linked to an owned work item

pkg/kubeapiserver/authenticator/config.go:268:3

267 for _, jwtAuthenticator := range config.JWT {
268 // TODO remove this CAContentProvider indirection
269 var oidcCAContent oidc.CAContentProvider

pkg/kubeapiserver/options/admission_test.go1

27:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/admission_test.go:27:6

26
27func TestValidate(t *testing.T) {
28 // 1. Both `--admission-control` and `--enable-admission-plugins` are specified

pkg/scheduler/backend/queue/scheduling_queue_test.go1

3726:7time-value-equalitycompare time.Time values with Time.Equal instead of == or !=

pkg/scheduler/backend/queue/scheduling_queue_test.go:3726:7

3725 // Verify that flush didn't happen
3726 if actualEntity.GetFlushTimestamp() != firstFlushTime {
3727 t.Errorf("Expected FlushTimestamp to remain %v, but was updated to %v (pod was flushed prematurely)", firstFlushTime, actualEntity.GetFlushTimestamp())

pkg/kubeapiserver/authenticator/config.go1

251:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/authenticator/config.go:251:1

250
251type jwtAuthenticatorWithCancel struct {
252 jwtAuthenticator authenticator.Token

pkg/proxy/healthcheck/healthcheck_test.go1

394:15unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/healthcheck/healthcheck_test.go:394:15

393 for _, h := range instance.httpServers {
394 handler := h.(*fakeHTTPServer).handler
395

pkg/proxy/healthcheck/common.go1

59:55unexported-returnexported function returns an unexported type

pkg/proxy/healthcheck/common.go:59:55

58
59func (stdHTTPServerFactory) New(handler http.Handler) httpServer {
60 return &http.Server{

pkg/kubeapiserver/options/authentication_test.go2

1770:44unused-parameterparameter listener is unused

pkg/kubeapiserver/options/authentication_test.go:1770:44

1769
1770func (d *dummyPublicKeyGetter) AddListener(listener serviceaccount.Listener) {}
1771
1770:7unused-receiverreceiver d is unused

pkg/kubeapiserver/options/authentication_test.go:1770:7

1769
1770func (d *dummyPublicKeyGetter) AddListener(listener serviceaccount.Listener) {}
1771

pkg/proxy/apis/config/fuzzer/fuzzer.go1

82:53use-anyuse any instead of interface{}

pkg/proxy/apis/config/fuzzer/fuzzer.go:82:53

81// Funcs returns the fuzzer functions for the kube-proxy apis.
82func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
83 return []interface{}{

pkg/kubeapiserver/authenticator/config.go1

396:15use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/authenticator/config.go:396:15

395 if publicKeysGetter == nil {
396 return nil, fmt.Errorf("no public key getter provided")
397 }

pkg/proxy/conntrack/cleanup_test.go1

340:2use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/conntrack/cleanup_test.go:340:2

339 // sort the expected flows before comparison
340 sort.Slice(entriesAfterCleanup, func(i, j int) bool {
341 return entriesAfterCleanup[i].String() < entriesAfterCleanup[j].String()

pkg/registry/core/service/storage/storage.go1

111:39var-declarationomit the explicit zero value from the variable declaration

pkg/registry/core/service/storage/storage.go:111:39

110 var primaryIPFamily api.IPFamily = serviceIPFamily
111 var secondaryIPFamily api.IPFamily = "" // sentinel value
112 if len(ipAllocs) > 1 {

pkg/proxy/endpointschangetracker_test.go1

309:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:309:2

308 }
309 multipleSubsets_s2 := func(eps *discovery.EndpointSlice) {
310 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/default_storage_factory_builder.go1

89:48add-constantstring literal "v1alpha3" appears more than twice; define a constant

pkg/kubeapiserver/default_storage_factory_builder.go:89:48

88 scheduling.Resource("workloads").WithVersion("v1alpha3"),
89 scheduling.Resource("podgroups").WithVersion("v1alpha3"),
90 scheduling.Resource("compositepodgroups").WithVersion("v1alpha3"),

pkg/registry/certificates/clustertrustbundle/strategy_test.go1

45:5boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/registry/certificates/clustertrustbundle/strategy_test.go:45:5

44func TestAllowUnconditionalUpdate(t *testing.T) {
45 if Strategy.AllowUnconditionalUpdate(context.Background()) != false {
46 t.Errorf("Got true, want false")

pkg/kubeapiserver/authorizer/config.go1

82:22cognitive-complexityfunction has cognitive complexity 15; maximum is 7

pkg/kubeapiserver/authorizer/config.go:82:22

81// Note: the cel compiler construction depends on feature gates and the compatibility version to be initialized.
82func (config Config) New(ctx context.Context, serverID string) (authorizer.Authorizer, authorizer.RuleResolver, error) {
83 if len(config.AuthorizationConfiguration.Authorizers) == 0 {

pkg/proxy/healthcheck/proxy_health.go1

93:6confusing-namingname newProxyHealthServer differs from NewProxyHealthServer only by capitalization

pkg/proxy/healthcheck/proxy_health.go:93:6

92
93func newProxyHealthServer(listener listener, httpServerFactory httpServerFactory, c clock.Clock, addr string, healthTimeout time.Duration, nodeManager nodeManager) *ProxyHealthServer {
94 return &ProxyHealthServer{

pkg/registry/certificates/podcertificaterequest/strategy_test.go1

484:114confusing-resultsadjacent unnamed results of the same type should be named

pkg/registry/certificates/podcertificaterequest/strategy_test.go:484:114

483
484func mustMakeEd25519KeyAndProof(t *testing.T, toBeSigned []byte) (ed25519.PrivateKey, ed25519.PublicKey, []byte, []byte) {
485 pub, priv, err := ed25519.GenerateKey(rand.Reader)

pkg/proxy/ipvs/netlink_linux.go1

40:6constructor-interface-returnNewNetLinkHandle returns interface NetLinkHandle although its concrete result is consistently *netlinkHandle; return the concrete type

pkg/proxy/ipvs/netlink_linux.go:40:6

39// NewNetLinkHandle will create a new NetLinkHandle
40func NewNetLinkHandle(isIPv6 bool) NetLinkHandle {
41 return &netlinkHandle{netlink.Handle{}, isIPv6}

pkg/registry/core/pod/storage/eviction.go1

375:34context-as-argumentcontext.Context should be the first parameter

pkg/registry/core/pod/storage/eviction.go:375:34

374
375func getPod(r *EvictionREST, ctx context.Context, name string) (*api.Pod, error) {
376 obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})

pkg/registry/core/pod/rest/authorize_test.go1

44:3context-stored-in-structdo not store context.Context in a struct; pass it explicitly to each operation

pkg/registry/core/pod/rest/authorize_test.go:44:3

43 name string
44 ctx context.Context
45 authorizer authorizer.UnconditionalAuthorizer

pkg/kubeapiserver/authorizer/reload.go1

100:40cyclomatic-complexityfunction complexity is 21; maximum is 10

pkg/kubeapiserver/authorizer/reload.go:100:40

99// newForConfig constructs
100func (r *reloadableAuthorizerResolver) newForConfig(authzConfig *authzconfig.AuthorizationConfiguration) (authorizer.Authorizer, authorizer.RuleResolver, error) {
101 if len(authzConfig.Authorizers) == 0 {

pkg/scheduler/framework/runtime/batch_test.go1

109:3deep-exitprocess-exit calls should be confined to main or init

pkg/scheduler/framework/runtime/batch_test.go:109:3

108 if err != nil {
109 log.Fatal("Couldn't register test.")
110 }

pkg/proxy/ipvs/ipset/testing/fake.go1

35:21deprecated-api-usagek8s.io/apimachinery/pkg/util/sets.String is deprecated: use generic Set instead. new ways: s1 := Set[string]{} s2 := New[string]()

pkg/proxy/ipvs/ipset/testing/fake.go:35:21

34 // The key of Entries map is the ip set name where the entries exists
35 Entries map[string]sets.String
36}

pkg/kubeapiserver/options/authentication_test.go1

1647:3discarded-error-resulterror result returned by fmt.Println is discarded

pkg/kubeapiserver/options/authentication_test.go:1647:3

1646 if err := pem.Encode(publicKeyFile, publicKeyBlock); err != nil {
1647 fmt.Println("Error encoding public key:", err)
1648 return

pkg/kubeapiserver/admission/initializer.go1

38:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/admission/initializer.go:38:1

37
38// NewPluginInitializer constructs new instance of PluginInitializer
39func NewPluginInitializer() *PluginInitializer {

pkg/proxy/servicechangetracker_test.go1

96:3early-returninvert the condition and return early to reduce nesting

pkg/proxy/servicechangetracker_test.go:96:3

95 for _, s := range cidrStr {
96 if _, n, err := netutils.ParseCIDRSloppy(s); err == nil {
97 cidrs = append(cidrs, n)

pkg/registry/batch/job/strategy.go1

207:12empty-conditional-blockempty block should be removed or documented

pkg/registry/batch/job/strategy.go:207:12

206 _, found := obj.Spec.Template.Labels[value]
207 if found {
208 // User asked us to automatically generate a selector, but set manual labels.

pkg/kubeapiserver/options/admission_test.go1

48:12error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/admission_test.go:48:12

47 if len(options.Validate()) == 0 {
48 t.Errorf("Expect error, but got none")
49 }

pkg/registry/core/service/portallocator/storage/storage_test.go1

85:2excessive-blank-identifiersassignment discards three or more results; name meaningful results or simplify the return contract

pkg/registry/core/service/portallocator/storage/storage_test.go:85:2

84func TestEmpty(t *testing.T) {
85 _, storage, _, _, destroyFunc := newStorage(t)
86 defer destroyFunc()

pkg/kubeapiserver/admission/initializer.go1

47:29exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/admission/initializer.go:47:29

46// and provide the appropriate initialization data
47func (i *PluginInitializer) Initialize(plugin admission.Interface) {
48 if wants, ok := plugin.(initializer.WantsManifestLoaders); ok {

pkg/proxy/apis/config/validation/validation_test.go1

1:1file-length-limitfile has 934 lines; maximum is 500

pkg/proxy/apis/config/validation/validation_test.go:1:1

1/*
2Copyright 2017 The Kubernetes Authors.

pkg/proxy/endpointschangetracker.go1

81:96flag-parameterboolean parameter removeSlice controls function flow

pkg/proxy/endpointschangetracker.go:81:96

80// ServiceChangeTracker.Update().
81func (ect *EndpointsChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.EndpointSlice, removeSlice bool) bool {
82 if endpointSlice.AddressType != ect.addressType {

pkg/kubeapiserver/admission/initializer.go1

1:1formatfile is not formatted

pkg/kubeapiserver/admission/initializer.go:1:1

1/*
2Copyright 2016 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/admission/initializer.go`

pkg/kubeapiserver/authorizer/reload.go1

100:40function-lengthfunction has 52 statements and 119 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/authorizer/reload.go:100:40

99// newForConfig constructs
100func (r *reloadableAuthorizerResolver) newForConfig(authzConfig *authzconfig.AuthorizationConfiguration) (authorizer.Authorizer, authorizer.RuleResolver, error) {
101 if len(authzConfig.Authorizers) == 0 {

pkg/proxy/topology.go1

48:6function-result-limitfunction returns 4 values; maximum is 3

pkg/proxy/topology.go:48:6

47// types or labels, ensure the filtering logic in NodeTopologyConfig is updated accordingly.
48func CategorizeEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeName string, topologyLabels map[string]string) (clusterEndpoints, localEndpoints, allReachableEndpoints []Endpoint, hasAnyEndpoints bool) {
49 if len(endpoints) == 0 {

pkg/kubeapiserver/authorizer/reload.go1

77:2import-shadowingidentifier authorizer shadows an imported package

pkg/kubeapiserver/authorizer/reload.go:77:2

76type authorizerResolver struct {
77 authorizer authorizer.Authorizer
78 ruleResolver authorizer.RuleResolver

pkg/registry/core/service/storage/transaction_test.go1

37:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:37:6

36 commit: func() {
37 temp = temp + 1
38 },

pkg/proxy/endpointslicecache.go1

263:29inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/endpointslicecache.go:263:29

262 if _, ok := cache.trackerByServiceMap[serviceKey]; ok {
263 appliedData, appliedOk := cache.trackerByServiceMap[serviceKey].applied[sliceKey]
264 pendingData, pendingOk := cache.trackerByServiceMap[serviceKey].pending[sliceKey]

pkg/proxy/iptables/proxier_test.go1

1353:83inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/proxy/iptables/proxier_test.go:1353:83

1352 }
1353 matches, output, masq := tracePacket(t, ipt, tc.sourceIP, protocol, tc.destIP, fmt.Sprintf("%d", tc.destPort), nodeIPs)
1354 var errors []string

pkg/kubeapiserver/options/authentication_test.go1

113:23insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:113:23

112 testSA: &ServiceAccountAuthenticationOptions{
113 Issuers: []string{"http://foo.bar.com"},
114 },

pkg/proxy/types.go1

28:15interface-method-limitinterface has 12 methods, exceeding the configured design limit of 10

pkg/proxy/types.go:28:15

27// Provider is the interface provided by proxier implementations.
28type Provider interface {
29 config.EndpointSliceHandler

pkg/scheduler/backend/queue/scheduling_queue_test.go1

2393:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/backend/queue/scheduling_queue_test.go:2393:8

2392 for k := 0; k < len(plugins); k++ {
2393 if (k+1)%(j+1) == 0 {
2394 m[""][events[j]] = append(m[""][events[j]], &QueueingHintFunction{

pkg/proxy/iptables/proxier.go1

94:6max-parametersfunction has 10 parameters; maximum is 8

pkg/proxy/iptables/proxier.go:94:6

93// NewDualStackProxier creates a MetaProxier instance, with IPv4 and IPv6 proxies.
94func NewDualStackProxier(
95 ctx context.Context,

pkg/proxy/apis/config/types.go1

90:6max-public-structsfile declares more than 5 exported structs

pkg/proxy/apis/config/types.go:90:6

89// the Kubernetes proxy server.
90type KubeProxyConntrackConfiguration struct {
91 // maxPerCore is the maximum number of NAT connections to track

pkg/kubeapiserver/options/authentication.go1

705:2modifies-parameterassignment modifies parameter authInfo

pkg/kubeapiserver/options/authentication.go:705:2

704 authInfo.RequestHeaderConfig = authenticatorConfig.RequestHeaderConfig
705 authInfo.APIAudiences = o.APIAudiences
706 if o.ServiceAccounts != nil && len(o.ServiceAccounts.Issuers) != 0 && len(o.APIAudiences) == 0 {

pkg/proxy/endpointslicecache.go1

329:8modifies-value-receiverassignment modifies value receiver e

pkg/proxy/endpointslicecache.go:329:8

328func (e byEndpoint) Swap(i, j int) {
329 e[i], e[j] = e[j], e[i]
330}

pkg/kubeapiserver/options/authentication_test.go1

59:17nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/authentication_test.go:59:17

58func TestAuthenticationValidate(t *testing.T) {
59 testCases := []struct {
60 name string

pkg/registry/core/service/allocator/storage/storage.go1

100:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/allocator/storage/storage.go:100:4

99 if err == errorUnableToAllocate {
100 return false, nil
101 }

pkg/proxy/iptables/proxier.go1

121:3nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/iptables/proxier.go:121:3

120 if initOnly {
121 return nil, nil
122 }

pkg/registry/admissionregistration/validatingadmissionpolicybinding/storage/storage_test.go1

61:3no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/registry/admissionregistration/validatingadmissionpolicybinding/storage/storage_test.go:61:3

60 storage, server := newInsecureStorage(t)
61 defer server.Terminate(t)
62 defer storage.Store.DestroyFunc()

pkg/proxy/ipvs/ipset/ipset.go1

349:5no-else-after-returnremove else and unindent its body after the return

pkg/proxy/ipvs/ipset/ipset.go:349:5

348 return false, nil
349 } else if e == nil {
350 return true, nil

pkg/proxy/apis/config/v1alpha1/register.go1

38:6no-initreplace init with explicit initialization

pkg/proxy/apis/config/v1alpha1/register.go:38:6

37
38func init() {
39 // We only register manually written functions here. The registration of the

pkg/proxy/iptables/proxier.go1

689:5no-naked-returnreturn values must be explicit

pkg/proxy/iptables/proxier.go:689:5

688 proxier.logger.Error(err, "Failed to ensure chain exists", "table", jump.table, "chain", jump.dstChain)
689 return
690 }

pkg/kubeapiserver/authorizer/config.go1

165:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/authorizer/config.go:165:5

164// RepeatableAuthorizerTypes is the list of Authorizer that can be repeated in the Authorization Config
165var repeatableAuthorizerTypes = []string{modes.ModeWebhook}
166

pkg/kubeapiserver/options/authentication.go1

307:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:307:6

306
307 if o.ClientCert != nil &&
308 len(o.ClientCert.ClientCA) > 0 &&

pkg/registry/node/runtimeclass/strategy.go1

64:2overwritten-before-usethis value of newRuntimeClass is overwritten before use

pkg/registry/node/runtimeclass/strategy.go:64:2

63func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
64 newRuntimeClass := obj.(*node.RuntimeClass)
65 oldRuntimeClass := old.(*node.RuntimeClass)

pkg/kubeapiserver/admission/initializer.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/admission/initializer.go:17:9

16
17package admission
18

pkg/proxy/ipvs/util/ipvs_linux.go1

19:9package-directory-mismatchpackage ipvs does not match directory util

pkg/proxy/ipvs/util/ipvs_linux.go:19:9

18
19package ipvs
20

pkg/registry/core/pod/storage/storage_test.go1

398:15possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/registry/core/pod/storage/storage_test.go:398:15

397
398 if location.Scheme != "" {
399 t.Errorf("Expected '%v', but got '%v'", "", location.Scheme)

pkg/proxy/conntrack/sysctls_test.go1

228:10range-value-addresstaking the address of range value test can be misleading

pkg/proxy/conntrack/sysctls_test.go:228:10

227 t.Run(test.name, func(t *testing.T) {
228 fc := &fakeConntracker{err: test.conntrackErr}
229 err := setSysctls(ctx, fc, &test.config)

pkg/proxy/winkernel/proxier.go1

884:7receiver-namingreceiver name svcInfo is inconsistent with info

pkg/proxy/winkernel/proxier.go:884:7

883
884func (svcInfo *serviceInfo) cleanupAllPolicies(endpoints []proxy.Endpoint, mapStaleLoadbalancers map[string]loadBalancerType, isEndpointChange bool, ipFamilyStr string) {
885 klog.V(3).InfoS("Service cleanup", "serviceInfo", svcInfo)

pkg/proxy/conntrack/sysctls.go1

146:64redefines-builtin-ididentifier max shadows a predeclared identifier

pkg/proxy/conntrack/sysctls.go:146:64

145
146func (rct realConntrackConfigurer) SetMax(ctx context.Context, max int) error {
147 logger := klog.FromContext(ctx)

pkg/proxy/apis/config/v1alpha1/defaults.go1

93:11redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/apis/config/v1alpha1/defaults.go:93:11

92 if obj.NFTables.MasqueradeBit == nil {
93 temp := int32(14)
94 obj.NFTables.MasqueradeBit = &temp

pkg/proxy/config/config_test.go1

37:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/config/config_test.go:37:2

36 "k8s.io/apimachinery/pkg/watch"
37 informers "k8s.io/client-go/informers"
38 "k8s.io/client-go/kubernetes/fake"

pkg/kubeapiserver/authorizer/reload.go1

164:4single-case-switchswitch with one case can be replaced by an if statement

pkg/kubeapiserver/authorizer/reload.go:164:4

163 var decisionOnError authorizer.Decision
164 switch configuredAuthorizer.Webhook.FailurePolicy {
165 case authzconfig.FailurePolicyNoOpinion:

pkg/proxy/apis/config/validation/validation.go1

296:2slice-preallocationpreallocate allErrs with capacity len(range source) before appending once per iteration

pkg/proxy/apis/config/validation/validation.go:296:2

295func validateShowHiddenMetricsVersion(version string, fldPath *field.Path) field.ErrorList {
296 allErrs := field.ErrorList{}
297 errs := metrics.ValidateShowHiddenMetricsVersion(version)

pkg/scheduler/extender.go1

407:30standard-http-method-constantreplace the HTTP method literal with http.MethodPost

pkg/scheduler/extender.go:407:30

406
407 req, err := http.NewRequest("POST", url, bytes.NewReader(out))
408 if err != nil {

pkg/kubeapiserver/authenticator/config.go1

347:3task-commentTODO comment should be resolved or linked to an owned work item

pkg/kubeapiserver/authenticator/config.go:347:3

346 }
347 // TODO maybe track requests so we know when this is safe to do
348 oldJWTAuthenticator.cancel()

pkg/kubeapiserver/options/admission_test.go1

65:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/admission_test.go:65:6

64
65func TestComputeEnabledAdmission(t *testing.T) {
66 tests := []struct {

pkg/scheduler/backend/queue/scheduling_queue_test.go1

3927:136time-value-equalitycompare time.Time values with Time.Equal instead of == or !=

pkg/scheduler/backend/queue/scheduling_queue_test.go:3927:136

3926 }
3927 if !test.expectPreservedTimestamp && (test.expectedInActiveQ || test.expectedInBackoffQ || test.expectedInUnschedulableEntities) && pgInfo.Timestamp != c.Now() {
3928 tCtx.Errorf("Expected timestamp to be %v, but got %v", c.Now(), pgInfo.Timestamp)

pkg/kubeapiserver/authorizer/config.go1

165:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/authorizer/config.go:165:1

164// RepeatableAuthorizerTypes is the list of Authorizer that can be repeated in the Authorization Config
165var repeatableAuthorizerTypes = []string{modes.ModeWebhook}
166

pkg/proxy/healthcheck/healthcheck_test.go2

896:26unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/healthcheck/healthcheck_test.go:896:26

895 t.Helper()
896 handler := hsTest.server.(*fakeHTTPServer).handler
897 req, err := http.NewRequest("GET", string(hsTest.url), nil)
103:62unexported-returnexported function returns an unexported type

pkg/proxy/healthcheck/healthcheck_test.go:103:62

102
103func (fake *fakeHTTPServerFactory) New(handler http.Handler) httpServer {
104 return &fakeHTTPServer{

pkg/kubeapiserver/options/authentication_test.go2

1776:46unused-parameterparameter ctx is unused

pkg/kubeapiserver/options/authentication_test.go:1776:46

1775
1776func (d *dummyPublicKeyGetter) GetPublicKeys(ctx context.Context, keyIDHint string) []serviceaccount.PublicKey {
1777 return []serviceaccount.PublicKey{}
1772:7unused-receiverreceiver d is unused

pkg/kubeapiserver/options/authentication_test.go:1772:7

1771
1772func (d *dummyPublicKeyGetter) GetCacheAgeMaxSeconds() int {
1773 return 10

pkg/proxy/apis/config/fuzzer/fuzzer.go1

83:11use-anyuse any instead of interface{}

pkg/proxy/apis/config/fuzzer/fuzzer.go:83:11

82func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
83 return []interface{}{
84 func(obj *kubeproxyconfig.KubeProxyConfiguration, c randfill.Continue) {

pkg/kubeapiserver/authorizer/config.go1

84:20use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/authorizer/config.go:84:20

83 if len(config.AuthorizationConfiguration.Authorizers) == 0 {
84 return nil, nil, fmt.Errorf("at least one authorization mode must be passed")
85 }

pkg/proxy/conntrack/cleanup_test.go1

556:2use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/conntrack/cleanup_test.go:556:2

555 // sort the actual flows before comparison
556 sort.Slice(actualEntries, func(i, j int) bool {
557 return actualEntries[i].String() < actualEntries[j].String()

pkg/proxy/endpointschangetracker_test.go1

319:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:319:2

318 }
319 multipleSubsetsWithLocal_s1 := func(eps *discovery.EndpointSlice) {
320 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/default_storage_factory_builder.go1

142:55add-constantstring literal "events" appears more than twice; define a constant

pkg/kubeapiserver/default_storage_factory_builder.go:142:55

141 storageFactory.AddCohabitatingResources(apps.Resource("replicasets"), extensions.Resource("replicasets"))
142 storageFactory.AddCohabitatingResources(api.Resource("events"), events.Resource("events"))
143 storageFactory.AddCohabitatingResources(api.Resource("replicationcontrollers"), extensions.Resource("replicationcontrollers")) // to make scale subresources equivalent

pkg/registry/certificates/podcertificaterequest/strategy_test.go1

51:5boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/registry/certificates/podcertificaterequest/strategy_test.go:51:5

50 strategy := NewStrategy()
51 if strategy.AllowCreateOnUpdate(context.Background()) != false {
52 t.Errorf("Got true, want false")

pkg/kubeapiserver/authorizer/config.go1

185:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

pkg/kubeapiserver/authorizer/config.go:185:6

184
185func LoadAndValidateData(data []byte, compiler authorizationcel.Compiler, requireNonWebhookTypes sets.Set[authzconfig.AuthorizerType]) (*authzconfig.AuthorizationConfiguration, error) {
186 // load the file and check for errors

pkg/proxy/healthcheck/service_health.go1

101:6confusing-namingname NewServiceHealthServer differs from newServiceHealthServer only by capitalization

pkg/proxy/healthcheck/service_health.go:101:6

100// NewServiceHealthServer allocates a new service healthcheck server manager
101func NewServiceHealthServer(nodeName string, recorder events.EventRecorder, nodePortAddresses *proxyutil.NodePortAddresses, healthzServer proxyHealthChecker, serviceFamily v1.IPFamily) ServiceHealthServer {
102 return newServiceHealthServer(nodeName, recorder, stdNetListener{}, stdHTTPServerFactory{}, nodePortAddresses, healthzServer, serviceFamily)

pkg/scheduler/backend/cache/snapshot_test.go1

1159:68confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/backend/cache/snapshot_test.go:1159:68

1158// simplifySnapshot for comparison in unit tests
1159func simplifySnapshot(s *Snapshot) (map[string][]string, []string, []string, []string, map[string]int, map[string][]string) {
1160 nodeInfoMap := make(map[string][]string)

pkg/proxy/ipvs/util/ipvs_linux.go1

45:6constructor-interface-returnNew returns interface Interface although its concrete result is consistently *runner; return the concrete type

pkg/proxy/ipvs/util/ipvs_linux.go:45:6

44// New returns a new Interface which will call ipvs APIs.
45func New() Interface {
46 handle, err := libipvs.New("")

pkg/scheduler/backend/queue/scheduling_queue_test.go1

6035:50context-as-argumentcontext.Context should be the first parameter

pkg/scheduler/backend/queue/scheduling_queue_test.go:6035:50

6034
6035func setupInitialPodGroupState(t *testing.T, ctx context.Context, q *PriorityQueue, initialPods []*v1.Pod, initialState initialQueueState, initialPodGroup *schedulingv1alpha3.PodGroup) {
6036 t.Helper()

pkg/kubeapiserver/options/authentication.go1

248:40cyclomatic-complexityfunction complexity is 27; maximum is 10

pkg/kubeapiserver/options/authentication.go:248:40

247// Validate checks invalid config combination
248func (o *BuiltInAuthenticationOptions) Validate() []error {
249 if o == nil {

pkg/scheduler/framework/runtime/batch_test.go1

113:3deep-exitprocess-exit calls should be confined to main or init

pkg/scheduler/framework/runtime/batch_test.go:113:3

112 if err != nil {
113 log.Fatal("Couldn't register test.")
114 }

pkg/proxy/ipvs/ipset/testing/fake.go1

43:28deprecated-api-usagek8s.io/apimachinery/pkg/util/sets.String is deprecated: use generic Set instead. new ways: s1 := Set[string]{} s2 := New[string]()

pkg/proxy/ipvs/ipset/testing/fake.go:43:28

42 Sets: make(map[string]*ipset.IPSet),
43 Entries: make(map[string]sets.String),
44 }

pkg/proxy/config/config.go1

85:28discarded-error-resulterror result returned by endpointSliceInformer.Informer().AddEventHandlerWithResyncPeriod is discarded

pkg/proxy/config/config.go:85:28

84
85 handlerRegistration, _ := endpointSliceInformer.Informer().AddEventHandlerWithResyncPeriod(
86 cache.ResourceEventHandlerFuncs{

pkg/kubeapiserver/admission/initializer.go1

45:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/admission/initializer.go:45:1

44
45// Initialize checks the initialization interfaces implemented by each plugin
46// and provide the appropriate initialization data

pkg/proxy/winkernel/proxier.go1

213:2early-returninvert the condition and return early to reduce nesting

pkg/proxy/winkernel/proxier.go:213:2

212 klog.V(3).InfoS("HNS Supported features", "hnsSupportedFeatures", supportedFeatures)
213 if supportedFeatures.Api.V2 {
214 h = hns{

pkg/registry/batch/job/strategy.go1

220:12empty-conditional-blockempty block should be removed or documented

pkg/registry/batch/job/strategy.go:220:12

219 _, found := obj.Spec.Template.Labels[value]
220 if found {
221 // User asked us to automatically generate a selector, but set manual labels.

pkg/kubeapiserver/options/admission_test.go1

55:12error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/admission_test.go:55:12

54 if errs := options.Validate(); len(errs) > 0 {
55 t.Errorf("Unexpected err: %v", errs)
56 }

pkg/scheduler/backend/cache/snapshot_test.go1

1651:5excessive-blank-identifiersassignment discards three or more results; name meaningful results or simplify the return contract

pkg/scheduler/backend/cache/snapshot_test.go:1651:5

1650 if tt.expectedPodGroups != nil {
1651 _, _, _, _, _, gotPGStates := simplifySnapshot(s)
1652 if diff := cmp.Diff(tt.expectedPodGroups, gotPGStates); diff != "" {

pkg/kubeapiserver/authenticator/config.go1

107:22exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/authenticator/config.go:107:22

106// Kubernetes authentication mechanisms.
107func (config Config) New(serverLifecycle context.Context) (authenticator.Request, func(context.Context, *apiserver.AuthenticationConfiguration) error, *spec.SecurityDefinitions, spec3.SecuritySchemes, error) {
108 var authenticators []authenticator.Request

pkg/proxy/config/config.go1

1:1file-length-limitfile has 532 lines; maximum is 500

pkg/proxy/config/config.go:1:1

1/*
2Copyright 2014 The Kubernetes Authors.

pkg/proxy/healthcheck/healthcheck_test.go1

391:81flag-parameterboolean parameter kubeProxyHealthy controls function flow

pkg/proxy/healthcheck/healthcheck_test.go:391:81

390
391func tHandler(hcs *server, nsn types.NamespacedName, status int, endpoints int, kubeProxyHealthy bool, t *testing.T) {
392 instance := hcs.services[nsn]

pkg/kubeapiserver/authenticator/config.go1

1:1formatfile is not formatted

pkg/kubeapiserver/authenticator/config.go:1:1

1/*
2Copyright 2014 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/authenticator/config.go`

pkg/kubeapiserver/options/authentication.go1

248:40function-lengthfunction has 40 statements and 77 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication.go:248:40

247// Validate checks invalid config combination
248func (o *BuiltInAuthenticationOptions) Validate() []error {
249 if o == nil {

pkg/registry/apps/deployment/storage/storage.go1

94:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/apps/deployment/storage/storage.go:94:6

93// NewREST returns a RESTStorage object that will work against deployments.
94func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST, error) {
95 store := &genericregistry.Store{

pkg/kubeapiserver/authorizer/reload.go1

95:70import-shadowingidentifier user shadows an imported package

pkg/kubeapiserver/authorizer/reload.go:95:70

94
95func (r *reloadableAuthorizerResolver) RulesFor(ctx context.Context, user user.Info, namespace string) ([]authorizer.ResourceRuleInfo, []authorizer.NonResourceRuleInfo, bool, error) {
96 return r.current.Load().ruleResolver.RulesFor(ctx, user, namespace)

pkg/registry/core/service/storage/transaction_test.go1

40:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:40:6

39 revert: func() {
40 temp = temp - 1
41 },

pkg/proxy/endpointslicecache.go1

264:29inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/endpointslicecache.go:264:29

263 appliedData, appliedOk := cache.trackerByServiceMap[serviceKey].applied[sliceKey]
264 pendingData, pendingOk := cache.trackerByServiceMap[serviceKey].pending[sliceKey]
265

pkg/proxy/ipvs/ipset/ipset.go1

233:10inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use the string value directly

pkg/proxy/ipvs/ipset/ipset.go:233:10

232 // Entry{192.168.1.1} -> 192.168.1.1
233 return fmt.Sprintf("%s", e.IP)
234 case HashIPPort:

pkg/kubeapiserver/options/authentication_test.go1

155:23insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:155:23

154 testSA: &ServiceAccountAuthenticationOptions{
155 Issuers: []string{"http://foo.bar.com", "http://foo.bar.com"},
156 },

pkg/registry/flowcontrol/ensurer/strategy.go1

99:26interface-method-limitinterface has 32 methods, exceeding the configured design limit of 10

pkg/registry/flowcontrol/ensurer/strategy.go:99:26

98// configurationObject is the relevant interfaces that each API object type implements
99type configurationObject interface {
100 metav1.Object

pkg/scheduler/backend/queue/scheduling_queue_test.go1

2422:14max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/backend/queue/scheduling_queue_test.go:2422:14

2421 podInfo = q.newQueuedPodInfo(ctx, p)
2422 } else if tt.name == "worst" {
2423 // Each pod failed by all plugins.

pkg/proxy/iptables/proxier.go1

209:6max-parametersfunction has 11 parameters; maximum is 8

pkg/proxy/iptables/proxier.go:209:6

208// NewProxier returns a new single-stack IPTables proxier.
209func NewProxier(ctx context.Context,
210 config *kubeproxyconfig.KubeProxyConfiguration,

pkg/proxy/apis/config/types.go1

120:6max-public-structsfile declares more than 5 exported structs

pkg/proxy/apis/config/types.go:120:6

119// the Kubernetes proxy server.
120type KubeProxyWinkernelConfiguration struct {
121 // networkName is the name of the network kube-proxy will use

pkg/kubeapiserver/options/authentication.go1

707:3modifies-parameterassignment modifies parameter authInfo

pkg/kubeapiserver/options/authentication.go:707:3

706 if o.ServiceAccounts != nil && len(o.ServiceAccounts.Issuers) != 0 && len(o.APIAudiences) == 0 {
707 authInfo.APIAudiences = authenticator.Audiences(o.ServiceAccounts.Issuers)
708 }

pkg/proxy/ipvs/util/testing/fake.go1

69:2modifies-value-receiverassignment modifies value receiver a

pkg/proxy/ipvs/util/testing/fake.go:69:2

68func (a byAddress) Swap(i, j int) {
69 a[i], a[j] = a[j], a[i]
70}

pkg/kubeapiserver/options/authentication_test.go1

543:17nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/authentication_test.go:543:17

542func TestToAuthenticationConfig_Anonymous(t *testing.T) {
543 testCases := []struct {
544 name string

pkg/registry/core/service/allocator/storage/storage.go1

129:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/allocator/storage/storage.go:129:4

128 if err == errorUnableToAllocate {
129 return offset, false, nil
130 }

pkg/proxy/iptables/proxier.go1

248:3nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/iptables/proxier.go:248:3

247 logger.Info("System initialized and --init-only specified")
248 return nil, nil
249 }

pkg/registry/admissionregistration/validatingadmissionpolicybinding/storage/storage_test.go1

62:3no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/registry/admissionregistration/validatingadmissionpolicybinding/storage/storage_test.go:62:3

61 defer server.Terminate(t)
62 defer storage.Store.DestroyFunc()
63 t.Run(b.Name, func(t *testing.T) {

pkg/proxy/ipvs/ipset/ipset.go1

351:5no-else-after-returnremove else and unindent its body after the return

pkg/proxy/ipvs/ipset/ipset.go:351:5

350 return true, nil
351 } else {
352 return false, fmt.Errorf("error testing entry: %s, error: %v", entry, e)

pkg/registry/certificates/certificates/storage/metrics.go1

69:6no-initreplace init with explicit initialization

pkg/registry/certificates/certificates/storage/metrics.go:69:6

68
69func init() {
70 registerMetricsOnce.Do(func() {

pkg/proxy/iptables/proxier.go1

698:5no-naked-returnreturn values must be explicit

pkg/proxy/iptables/proxier.go:698:5

697 proxier.logger.Error(err, "Failed to ensure chain jumps", "table", jump.table, "srcChain", jump.srcChain, "dstChain", jump.dstChain)
698 return
699 }

pkg/kubeapiserver/authorizer/modes/modes.go1

37:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/authorizer/modes/modes.go:37:5

36// AuthorizationModeChoices is the list of supported authorization modes
37var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABAC, ModeWebhook, ModeRBAC, ModeNode}
38

pkg/kubeapiserver/options/authentication.go1

307:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:307:6

306
307 if o.ClientCert != nil &&
308 len(o.ClientCert.ClientCA) > 0 &&

pkg/registry/node/runtimeclass/strategy.go1

65:2overwritten-before-usethis value of oldRuntimeClass is overwritten before use

pkg/registry/node/runtimeclass/strategy.go:65:2

64 newRuntimeClass := obj.(*node.RuntimeClass)
65 oldRuntimeClass := old.(*node.RuntimeClass)
66

pkg/kubeapiserver/authenticator/config.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/authenticator/config.go:17:9

16
17package authenticator
18

pkg/proxy/ipvs/util/ipvs_linux_test.go1

19:9package-directory-mismatchpackage ipvs does not match directory util

pkg/proxy/ipvs/util/ipvs_linux_test.go:19:9

18
19package ipvs
20

pkg/registry/core/pod/storage/storage_test.go1

399:57possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/registry/core/pod/storage/storage_test.go:399:57

398 if location.Scheme != "" {
399 t.Errorf("Expected '%v', but got '%v'", "", location.Scheme)
400 }

pkg/proxy/conntrack/sysctls_test.go1

229:31range-value-addresstaking the address of range value test can be misleading

pkg/proxy/conntrack/sysctls_test.go:229:31

228 fc := &fakeConntracker{err: test.conntrackErr}
229 err := setSysctls(ctx, fc, &test.config)
230 if test.wantErr && err == nil {

pkg/proxy/winkernel/proxier.go1

912:7receiver-namingreceiver name svcInfo is inconsistent with info

pkg/proxy/winkernel/proxier.go:912:7

911
912func (svcInfo *serviceInfo) deleteLoadBalancerPolicy(mapStaleLoadbalancer map[string]loadBalancerType, ipFamilyStr string) {
913 // Remove the Hns Policy corresponding to this service

pkg/proxy/conntrack/sysctls_test.go1

42:3redefines-builtin-ididentifier min shadows a predeclared identifier

pkg/proxy/conntrack/sysctls_test.go:42:3

41 testCases := []struct {
42 min int32
43 maxPerCore int32

pkg/proxy/apis/config/v1alpha1/defaults_test.go1

34:14redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/apis/config/v1alpha1/defaults_test.go:34:14

33func TestDefaultsKubeProxyConfiguration(t *testing.T) {
34 oomScore := int32(-999)
35 ctMaxPerCore := int32(32768)

pkg/proxy/conntrack/cleanup.go1

30:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/conntrack/cleanup.go:30:2

29
30 v1 "k8s.io/api/core/v1"
31 "k8s.io/apimachinery/pkg/util/sets"

pkg/kubeapiserver/options/authentication.go1

589:3single-case-switchswitch with one case can be replaced by an if statement

pkg/kubeapiserver/options/authentication.go:589:3

588 if o.Anonymous != nil {
589 switch {
590 case ret.AuthenticationConfig.Anonymous != nil && o.Anonymous.FlagsSet:

pkg/proxy/conntrack/cleanup_test.go1

252:6slice-preallocationpreallocate entriesBeforeCleanup with capacity len(range source) before appending once per iteration

pkg/proxy/conntrack/cleanup_test.go:252:6

251 // {entriesBeforeCleanup} - {entriesAfterCleanup} = entries cleared by conntrack reconciler
252 var entriesBeforeCleanup []*netlink.ConntrackFlow
253 // entriesBeforeCleanup - entriesAfterCleanup = entries cleared by conntrack reconciler

pkg/scheduler/metrics/resources/resources_test.go1

90:30standard-http-method-constantreplace the HTTP method literal with http.MethodGet

pkg/scheduler/metrics/resources/resources_test.go:90:30

89 r := httptest.NewRecorder()
90 req, err := http.NewRequest("GET", "/metrics/resources", nil)
91 if err != nil {

pkg/kubeapiserver/default_storage_factory_builder.go1

80:3task-commentTODO comment should be resolved or linked to an owned work item

pkg/kubeapiserver/default_storage_factory_builder.go:80:3

79 //
80 // TODO (https://github.com/kubernetes/kubernetes/issues/108451): remove the override in 1.25.
81 // apisstorage.Resource("csistoragecapacities").WithVersion("v1beta1"),

pkg/kubeapiserver/options/admission_test.go1

87:18test-parallelismconsider calling t.Parallel() when this subtest begins

pkg/kubeapiserver/options/admission_test.go:87:18

86 for _, tc := range tests {
87 t.Run(tc.name, func(t *testing.T) {
88 actualEnabled, actualDisabled := computePluginNames(tc.enabled, tc.all)

pkg/scheduler/backend/queue/scheduling_queue_test.go1

4823:7time-value-equalitycompare time.Time values with Time.Equal instead of == or !=

pkg/scheduler/backend/queue/scheduling_queue_test.go:4823:7

4822 }
4823 if *entity.GetInitialAttemptTimestamp() != test.wantInitialAttemptTs {
4824 t.Errorf("Pod initial schedule attempt timestamp unexpected, got %v, want %v", *entity.GetInitialAttemptTimestamp(), test.wantInitialAttemptTs)

pkg/kubeapiserver/authorizer/reload.go1

220:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/authorizer/reload.go:220:1

219
220type kubeapiserverWebhookMetrics struct {
221 // kube-apiserver doesn't report request metrics

pkg/proxy/healthcheck/healthcheck_test.go1

976:13unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/healthcheck/healthcheck_test.go:976:13

975 hcsi := newServiceHealthServer("hostname", nil, listener, httpFactory, nodePortAddresses, proxyChecker, v1.IPv4Protocol)
976 hcs := hcsi.(*server)
977 if len(hcs.services) != 0 {

pkg/registry/admissionregistration/mutatingadmissionpolicy/strategy.go1

45:109unexported-returnexported function returns an unexported type

pkg/registry/admissionregistration/mutatingadmissionpolicy/strategy.go:45:109

44// NewStrategy is the default logic that applies when creating and updating MutatingAdmissionPolicy objects.
45func NewStrategy(authorizer authorizer.UnconditionalAuthorizer, resourceResolver resolver.ResourceResolver) *mutatingAdmissionPolicyStrategy {
46 return &mutatingAdmissionPolicyStrategy{

pkg/kubeapiserver/options/authentication_test.go2

1776:67unused-parameterparameter keyIDHint is unused

pkg/kubeapiserver/options/authentication_test.go:1776:67

1775
1776func (d *dummyPublicKeyGetter) GetPublicKeys(ctx context.Context, keyIDHint string) []serviceaccount.PublicKey {
1777 return []serviceaccount.PublicKey{}
1776:7unused-receiverreceiver d is unused

pkg/kubeapiserver/options/authentication_test.go:1776:7

1775
1776func (d *dummyPublicKeyGetter) GetPublicKeys(ctx context.Context, keyIDHint string) []serviceaccount.PublicKey {
1777 return []serviceaccount.PublicKey{}

pkg/proxy/config/config.go1

118:58use-anyuse any instead of interface{}

pkg/proxy/config/config.go:118:58

117
118func (c *EndpointSliceConfig) handleAddEndpointSlice(obj interface{}) {
119 endpointSlice, ok := obj.(*discoveryv1.EndpointSlice)

pkg/kubeapiserver/authorizer/reload.go1

102:20use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/authorizer/reload.go:102:20

101 if len(authzConfig.Authorizers) == 0 {
102 return nil, nil, fmt.Errorf("at least one authorization mode must be passed")
103 }

pkg/proxy/conntrack/cleanup_test.go1

560:2use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/conntrack/cleanup_test.go:560:2

559 // sort the expected flows before comparison
560 sort.Slice(entriesAfterCleanup, func(i, j int) bool {
561 return entriesAfterCleanup[i].String() < entriesAfterCleanup[j].String()

pkg/proxy/endpointschangetracker_test.go1

329:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:329:2

328 }
329 multipleSubsetsWithLocal_s2 := func(eps *discovery.EndpointSlice) {
330 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/admission.go1

84:12add-constantstring literal "admission-control" appears more than twice; define a constant

pkg/kubeapiserver/options/admission.go:84:12

83 fs.MarkDeprecated("admission-control", "Use --enable-admission-plugins or --disable-admission-plugins instead. Will be removed in a future version.")
84 fs.Lookup("admission-control").Hidden = false
85

pkg/registry/certificates/podcertificaterequest/strategy_test.go1

67:5boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/registry/certificates/podcertificaterequest/strategy_test.go:67:5

66 strategy := NewStrategy()
67 if strategy.AllowUnconditionalUpdate(context.Background()) != false {
68 t.Errorf("Got true, want false")

pkg/kubeapiserver/authorizer/reload.go1

100:40cognitive-complexityfunction has cognitive complexity 35; maximum is 7

pkg/kubeapiserver/authorizer/reload.go:100:40

99// newForConfig constructs
100func (r *reloadableAuthorizerResolver) newForConfig(authzConfig *authzconfig.AuthorizationConfiguration) (authorizer.Authorizer, authorizer.RuleResolver, error) {
101 if len(authzConfig.Authorizers) == 0 {

pkg/proxy/ipvs/cleanup.go1

91:6confusing-namingname cleanupLeftovers differs from CleanupLeftovers only by capitalization

pkg/proxy/ipvs/cleanup.go:91:6

90
91func cleanupLeftovers(ctx context.Context, ipvs utilipvs.Interface, ipts map[v1.IPFamily]utiliptables.Interface, ipset utilipset.Interface) (encounteredError bool) {
92 logger := klog.FromContext(ctx)

pkg/scheduler/backend/cache/snapshot_test.go1

1159:78confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/backend/cache/snapshot_test.go:1159:78

1158// simplifySnapshot for comparison in unit tests
1159func simplifySnapshot(s *Snapshot) (map[string][]string, []string, []string, []string, map[string]int, map[string][]string) {
1160 nodeInfoMap := make(map[string][]string)

pkg/proxy/util/linebuffer.go1

60:6constructor-interface-returnNewLineBuffer returns interface LineBuffer although its concrete result is consistently *realLineBuffer; return the concrete type

pkg/proxy/util/linebuffer.go:60:6

59// NewLineBuffer returns a new "real" LineBuffer
60func NewLineBuffer() LineBuffer {
61 return &realLineBuffer{}

pkg/scheduler/framework/plugins/volumebinding/binder_test.go1

148:38context-as-argumentcontext.Context should be the first parameter

pkg/scheduler/framework/plugins/volumebinding/binder_test.go:148:38

147
148func newTestBinder(t *testing.T, ctx context.Context) *testEnv {
149 client := &fake.Clientset{}

pkg/kubeapiserver/options/authentication.go1

490:40cyclomatic-complexityfunction complexity is 44; maximum is 10

pkg/kubeapiserver/options/authentication.go:490:40

489// an empty config if o is nil.
490func (o *BuiltInAuthenticationOptions) ToAuthenticationConfig() (kubeauthenticator.Config, error) {
491 if o == nil {

pkg/registry/batch/job/storage/storage.go1

103:59deprecated-api-usagek8s.io/apimachinery/pkg/apis/meta/v1.OrphanDependents is deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. +optional

pkg/registry/batch/job/storage/storage.go:103:59

102 //nolint: staticcheck
103 if options != nil && options.PropagationPolicy == nil && options.OrphanDependents == nil &&
104 job.Strategy.DefaultGarbageCollectionPolicy(ctx) == rest.OrphanDependents {

pkg/proxy/config/config.go1

179:28discarded-error-resulterror result returned by serviceInformer.Informer().AddEventHandlerWithResyncPeriod is discarded

pkg/proxy/config/config.go:179:28

178
179 handlerRegistration, _ := serviceInformer.Informer().AddEventHandlerWithResyncPeriod(
180 cache.ResourceEventHandlerFuncs{

pkg/kubeapiserver/authenticator/config.go1

57:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authenticator/config.go:57:1

56
57// Config contains the data on how to authenticate a request to the Kube API Server
58type Config struct {

pkg/registry/core/service/ipallocator/ipallocator.go1

600:3early-returninvert the condition and return early to reduce nesting

pkg/registry/core/service/ipallocator/ipallocator.go:600:3

599 for i := len(bytes) - 1; i >= 0 && n > 0; i-- {
600 if n >= 8 {
601 bytes[i] = 0xff

pkg/scheduler/testing/framework/fake_extender.go1

267:24empty-conditional-blockempty block should be removed or documented

pkg/scheduler/testing/framework/fake_extender.go:267:24

266 status := f.runPredicate(pod, nodeInfoCopy)
267 if status.IsSuccess() {
268 // pass

pkg/kubeapiserver/options/authentication_test.go1

305:14error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/authentication_test.go:305:14

304 if len(errs) > 0 && (!strings.Contains(utilerrors.NewAggregate(errs).Error(), testcase.expectErr) || testcase.expectErr == "") {
305 t.Errorf("Got err: %v, Expected err: %s", errs, testcase.expectErr)
306 }

pkg/scheduler/framework/plugins/interpodaffinity/filtering_test.go1

1272:4excessive-blank-identifiersassignment discards three or more results; name meaningful results or simplify the return contract

pkg/scheduler/framework/plugins/interpodaffinity/filtering_test.go:1272:4

1271 // allPodsState is the state produced when all pods, including test.addedPod are given to prefilter.
1272 _, _, allPodsState, _ := getState(append(test.existingPods, test.addedPod))
1273

pkg/kubeapiserver/authorizer/config.go1

82:22exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/authorizer/config.go:82:22

81// Note: the cel compiler construction depends on feature gates and the compatibility version to be initialized.
82func (config Config) New(ctx context.Context, serverID string) (authorizer.Authorizer, authorizer.RuleResolver, error) {
83 if len(config.AuthorizationConfiguration.Authorizers) == 0 {

pkg/proxy/config/config_test.go1

1:1file-length-limitfile has 861 lines; maximum is 500

pkg/proxy/config/config_test.go:1:1

1/*
2Copyright 2014 The Kubernetes Authors.

pkg/proxy/iptables/proxier.go1

104:2flag-parameterboolean parameter initOnly controls function flow

pkg/proxy/iptables/proxier.go:104:2

103 healthzServer *healthcheck.ProxyHealthServer,
104 initOnly bool,
105) (proxy.Provider, error) {

pkg/kubeapiserver/authorizer/config.go1

1:1formatfile is not formatted

pkg/kubeapiserver/authorizer/config.go:1:1

1/*
2Copyright 2016 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/authorizer/config.go`

pkg/kubeapiserver/options/authentication.go1

340:40function-lengthfunction has 45 statements and 147 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication.go:340:40

339// AddFlags returns flags of authentication for a API Server
340func (o *BuiltInAuthenticationOptions) AddFlags(fs *pflag.FlagSet) {
341 if o == nil {

pkg/registry/certificates/certificates/storage/storage.go1

41:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/certificates/certificates/storage/storage.go:41:6

40// NewREST returns a registry which will store CertificateSigningRequest in the given helper.
41func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *ApprovalREST, error) {
42 store := &genericregistry.Store{

pkg/kubeapiserver/authorizer/reload.go1

278:2import-shadowingidentifier authorizer shadows an imported package

pkg/kubeapiserver/authorizer/reload.go:278:2

277
278 authorizer, ruleResolver, err := r.newForConfig(config)
279 if err != nil {

pkg/registry/core/service/storage/transaction_test.go1

50:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:50:6

49 commit: func() {
50 temp = temp + 1
51 },

pkg/proxy/healthcheck/proxy_health.go1

126:3inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/healthcheck/proxy_health.go:126:3

125 if _, set := hs.oldestPendingQueuedMap[ipFamily]; !set {
126 hs.oldestPendingQueuedMap[ipFamily] = hs.clock.Now()
127 }

pkg/proxy/nftables/helpers_test.go1

644:83inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/proxy/nftables/helpers_test.go:644:83

643 }
644 matches, output, masq := tracePacket(t, nft, tc.sourceIP, protocol, tc.destIP, fmt.Sprintf("%d", tc.destPort), nodeIPs)
645 var errors []string

pkg/kubeapiserver/options/authentication_test.go1

155:45insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:155:45

154 testSA: &ServiceAccountAuthenticationOptions{
155 Issuers: []string{"http://foo.bar.com", "http://foo.bar.com"},
156 },

pkg/registry/flowcontrol/ensurer/strategy.go1

106:30interface-method-limitinterface has 32 methods, exceeding the configured design limit of 10

pkg/registry/flowcontrol/ensurer/strategy.go:106:30

105// only usable as a type constraint.
106type configurationObjectType interface {
107 comparable

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go1

2570:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go:2570:8

2569 for _, expPod := range test.expectedPods {
2570 if expPod == victimName {
2571 found = true

pkg/proxy/ipvs/proxier.go1

110:6max-parametersfunction has 12 parameters; maximum is 8

pkg/proxy/ipvs/proxier.go:110:6

109// NewDualStackProxier returns a new Proxier for dual-stack operation
110func NewDualStackProxier(
111 ctx context.Context,

pkg/proxy/apis/config/types.go1

139:6max-public-structsfile declares more than 5 exported structs

pkg/proxy/apis/config/types.go:139:6

138// DetectLocalConfiguration contains optional settings related to DetectLocalMode option
139type DetectLocalConfiguration struct {
140 // bridgeInterface is a bridge interface name. When DetectLocalMode is set to

pkg/kubeapiserver/options/authentication.go1

750:2modifies-parameterassignment modifies parameter authInfo

pkg/kubeapiserver/options/authentication.go:750:2

749 }
750 authInfo.Authenticator = authenticator
751

pkg/proxy/ipvs/util/testing/fake.go1

69:8modifies-value-receiverassignment modifies value receiver a

pkg/proxy/ipvs/util/testing/fake.go:69:8

68func (a byAddress) Swap(i, j int) {
69 a[i], a[j] = a[j], a[i]
70}

pkg/kubeapiserver/options/authentication_test.go1

796:17nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/authentication_test.go:796:17

795func TestToAuthenticationConfig_OIDC(t *testing.T) {
796 testCases := []struct {
797 name string

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

133:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:133:4

132 t.Logf("unexpected error %v", err)
133 return false, nil
134 }

pkg/proxy/ipvs/proxier.go1

139:3nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/ipvs/proxier.go:139:3

138 if initOnly {
139 return nil, nil
140 }

pkg/registry/core/service/ipallocator/ipallocator_test.go1

388:3no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/registry/core/service/ipallocator/ipallocator_test.go:388:3

387 }
388 defer r.Destroy()
389

pkg/proxy/nftables/helpers_test.go1

506:7no-else-after-returnremove else and unindent its body after the return

pkg/proxy/nftables/helpers_test.go:506:7

505 return true
506 } else if action == "goto" {
507 // After a goto, return to our calling chain

pkg/registry/flowcontrol/ensurer/flowschema_test.go1

38:6no-initreplace init with explicit initialization

pkg/registry/flowcontrol/ensurer/flowschema_test.go:38:6

37
38func init() {
39 klog.InitFlags(nil)

pkg/proxy/iptables/proxier.go1

1393:3no-naked-returnreturn values must be explicit

pkg/proxy/iptables/proxier.go:1393:3

1392 metrics.IPTablesRestoreFailuresTotal.WithLabelValues(string(proxier.ipFamily)).Inc()
1393 return
1394 }

pkg/kubeapiserver/default_storage_factory_builder.go1

45:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/default_storage_factory_builder.go:45:5

44// SpecialDefaultResourcePrefixes are prefixes compiled into Kubernetes.
45var SpecialDefaultResourcePrefixes = map[schema.GroupResource]string{
46 {Group: "", Resource: "replicationcontrollers"}: "controllers",

pkg/kubeapiserver/options/authentication.go1

528:12optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:528:12

527 ret.OIDCSigningAlgs = oidc.AllValidSigningAlgorithms()
528 } else if o.OIDC != nil && len(o.OIDC.IssuerURL) > 0 && len(o.OIDC.ClientID) > 0 {
529 usernamePrefix := o.OIDC.UsernamePrefix

pkg/registry/rbac/clusterrole/strategy.go1

66:2overwritten-before-usethis value of newClusterRole is overwritten before use

pkg/registry/rbac/clusterrole/strategy.go:66:2

65func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
66 newClusterRole := obj.(*rbac.ClusterRole)
67 oldClusterRole := old.(*rbac.ClusterRole)

pkg/kubeapiserver/authorizer/config.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/authorizer/config.go:17:9

16
17package authorizer
18

pkg/proxy/ipvs/util/ipvs_test.go1

19:9package-directory-mismatchpackage ipvs does not match directory util

pkg/proxy/ipvs/util/ipvs_test.go:19:9

18
19package ipvs
20

pkg/registry/core/pod/storage/storage_test.go1

401:15possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/registry/core/pod/storage/storage_test.go:401:15

400 }
401 if location.Host != tc.location {
402 t.Errorf("Expected %v, but got %v", tc.location, location.Host)

pkg/proxy/endpointslicecache_test.go1

500:14range-value-addresstaking the address of range value tc can be misleading

pkg/proxy/endpointslicecache_test.go:500:14

499
500 esData := &endpointSliceData{tc.updatedSlice, false}
501 changed := tc.cache.esDataChanged(serviceKey, sliceKey, esData)

pkg/registry/core/componentstatus/rest.go1

68:7receiver-namingreceiver name r is inconsistent with rs

pkg/registry/core/componentstatus/rest.go:68:7

67// Destroy cleans up resources on shutdown.
68func (r *REST) Destroy() {
69 // Given no underlying store, we don't destroy anything

pkg/proxy/conntrack/sysctls_test.go1

92:56redefines-builtin-ididentifier max shadows a predeclared identifier

pkg/proxy/conntrack/sysctls_test.go:92:56

91// SetMax value is calculated based on the number of CPUs by getConntrackMax()
92func (fc *fakeConntracker) SetMax(ctx context.Context, max int) error {
93 fc.called = append(fc.called, "SetMax")

pkg/proxy/apis/config/v1alpha1/defaults_test.go1

35:18redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/apis/config/v1alpha1/defaults_test.go:35:18

34 oomScore := int32(-999)
35 ctMaxPerCore := int32(32768)
36 ctMin := int32(131072)

pkg/proxy/conntrack/cleanup_test.go1

32:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/conntrack/cleanup_test.go:32:2

31
32 v1 "k8s.io/api/core/v1"
33 discovery "k8s.io/api/discovery/v1"

pkg/kubeapiserver/options/authentication.go1

620:3single-case-switchswitch with one case can be replaced by an if statement

pkg/kubeapiserver/options/authentication.go:620:3

619
620 switch {
621 case len(o.ServiceAccounts.KeyFiles) > 0 && o.ServiceAccounts.ExternalPublicKeysGetter != nil:

pkg/proxy/endpointschangetracker.go1

260:6slice-preallocationpreallocate formattedList with capacity len(range source) before appending once per iteration

pkg/proxy/endpointschangetracker.go:260:6

259func formatEndpointsList(endpoints []Endpoint) []string {
260 var formattedList []string
261 for _, ep := range endpoints {

pkg/kubeapiserver/default_storage_factory_builder.go1

83:72task-commentTODO comment should be resolved or linked to an owned work item

pkg/kubeapiserver/default_storage_factory_builder.go:83:72

82 coordination.Resource("leasecandidates").WithVersion("v1beta1"),
83 certificates.Resource("clustertrustbundles").WithVersion("v1beta1"), // TODO: remove in 1.38
84 certificates.Resource("podcertificaterequests").WithVersion("v1beta1"),

pkg/kubeapiserver/options/admission_test.go1

99:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/admission_test.go:99:6

98
99func TestAdmissionOptionsAddFlags(t *testing.T) {
100 var args = []string{

pkg/kubeapiserver/default_storage_factory_builder.go1

100:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/default_storage_factory_builder.go:100:1

99// StorageFactoryConfig is a configuration for creating storage factory.
100type StorageFactoryConfig struct {
101 StorageConfig storagebackend.Config

pkg/proxy/ipvs/proxier_test.go1

1908:22unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/ipvs/proxier_test.go:1908:22

1907 addrs1 := []net.Addr{&net.IPNet{IP: netutils.ParseIPSloppy("2001:db8::"), Mask: net.CIDRMask(64, 128)}}
1908 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf, addrs)
1909 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf1, addrs1)

pkg/registry/admissionregistration/mutatingadmissionpolicybinding/strategy.go1

52:136unexported-returnexported function returns an unexported type

pkg/registry/admissionregistration/mutatingadmissionpolicybinding/strategy.go:52:136

51// NewStrategy is the default logic that applies when creating and updating MutatingAdmissionPolicyBinding objects.
52func NewStrategy(authorizer authorizer.UnconditionalAuthorizer, policyGetter PolicyGetter, resourceResolver resolver.ResourceResolver) *mutatingAdmissionPolicyBindingStrategy {
53 return &mutatingAdmissionPolicyBindingStrategy{

pkg/proxy/apis/config/fuzzer/fuzzer.go1

82:12unused-parameterparameter codecs is unused

pkg/proxy/apis/config/fuzzer/fuzzer.go:82:12

81// Funcs returns the fuzzer functions for the kube-proxy apis.
82func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
83 return []interface{}{

pkg/proxy/apis/config/types.go1

271:7unused-receiverreceiver m is unused

pkg/proxy/apis/config/types.go:271:7

270
271func (m *ProxyMode) Type() string {
272 return "ProxyMode"

pkg/proxy/config/config.go1

130:72use-anyuse any instead of interface{}

pkg/proxy/config/config.go:130:72

129
130func (c *EndpointSliceConfig) handleUpdateEndpointSlice(oldObj, newObj interface{}) {
131 oldEndpointSlice, ok := oldObj.(*discoveryv1.EndpointSlice)

pkg/kubeapiserver/authorizer/reload.go1

122:22use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/authorizer/reload.go:122:22

121 if r.nodeAuthorizer == nil {
122 return nil, nil, fmt.Errorf("authorizer type Node is not allowed if it was not enabled at initial server startup")
123 }

pkg/proxy/iptables/proxier_test.go1

665:2use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/iptables/proxier_test.go:665:2

664 // Sort tables
665 sort.Slice(dump.Tables, func(i, j int) bool {
666 return dump.Tables[i].Name < dump.Tables[j].Name

pkg/proxy/endpointschangetracker_test.go1

340:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:340:2

339 }
340 multipleSubsetsMultiplePortsLocal_s1 := func(eps *discovery.EndpointSlice) {
341 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/admission_test.go1

48:12add-constantstring literal "Expect error, but got none" appears more than twice; define a constant

pkg/kubeapiserver/options/admission_test.go:48:12

47 if len(options.Validate()) == 0 {
48 t.Errorf("Expect error, but got none")
49 }

pkg/registry/core/namespace/storage/storage.go1

281:10boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/registry/core/namespace/storage/storage.go:281:10

280 if options.OrphanDependents != nil {
281 return *options.OrphanDependents == false
282 }

pkg/kubeapiserver/options/authentication.go1

248:40cognitive-complexityfunction has cognitive complexity 47; maximum is 7

pkg/kubeapiserver/options/authentication.go:248:40

247// Validate checks invalid config combination
248func (o *BuiltInAuthenticationOptions) Validate() []error {
249 if o == nil {

pkg/proxy/ipvs/ipset/ipset.go1

300:23confusing-namingname createSet differs from CreateSet only by capitalization

pkg/proxy/ipvs/ipset/ipset.go:300:23

299// otherwise raised when the same set (setname and create parameters are identical) already exists.
300func (runner *runner) createSet(set *IPSet, ignoreExistErr bool) error {
301 args := []string{"create", set.Name, string(set.SetType)}

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go1

230:80confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go:230:80

229// of candidates that should be shortlisted for dry running preemption.
230func (pl *DefaultPreemption) GetOffsetAndNumCandidates(numNodes int32) (int32, int32) {
231 return getOffsetRand(numNodes), pl.calculateNumCandidates(numNodes)

pkg/proxy/util/linebuffer.go1

128:6constructor-interface-returnNewDiscardLineBuffer returns interface LineBuffer although its concrete result is consistently *discardLineBuffer; return the concrete type

pkg/proxy/util/linebuffer.go:128:6

127// how many rules we managed to avoid having to sync.)
128func NewDiscardLineBuffer() LineBuffer {
129 return &discardLineBuffer{}

pkg/kubeapiserver/options/authentication.go1

670:40cyclomatic-complexityfunction complexity is 27; maximum is 10

pkg/kubeapiserver/options/authentication.go:670:40

669// The input context controls the lifecycle of background goroutines started to reload the authentication config file.
670func (o *BuiltInAuthenticationOptions) ApplyTo(
671 ctx context.Context,

pkg/registry/batch/job/storage/storage.go1

114:47deprecated-api-usagek8s.io/apimachinery/pkg/apis/meta/v1.OrphanDependents is deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. +optional

pkg/registry/batch/job/storage/storage.go:114:47

113 //nolint:staticcheck // SA1019 backwards compatibility
114 if deleteOptions.PropagationPolicy == nil && deleteOptions.OrphanDependents == nil &&
115 job.Strategy.DefaultGarbageCollectionPolicy(ctx) == rest.OrphanDependents {

pkg/proxy/config/config.go1

288:28discarded-error-resulterror result returned by nodeInformer.Informer().AddEventHandlerWithResyncPeriod is discarded

pkg/proxy/config/config.go:288:28

287
288 handlerRegistration, _ := nodeInformer.Informer().AddEventHandlerWithResyncPeriod(
289 cache.ResourceEventHandlerFuncs{

pkg/kubeapiserver/authorizer/config.go1

48:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/config.go:48:1

47
48// Config contains the data on how to authorize a request to the Kube API Server
49type Config struct {

pkg/registry/flowcontrol/ensurer/strategy.go1

347:3early-returninvert the condition and return early to reduce nesting

pkg/registry/flowcontrol/ensurer/strategy.go:347:3

346 }
347 if apierrors.IsNotFound(err) {
348 klog.V(5).InfoS("Unwanted APF object was concurrently deleted", "name", name)

pkg/kubeapiserver/options/authentication_test.go1

308:14error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/authentication_test.go:308:14

307 if len(errs) == 0 && len(testcase.expectErr) != 0 {
308 t.Errorf("Got err nil, Expected err: %s", testcase.expectErr)
309 }

pkg/scheduler/schedule_one_test.go1

3956:4excessive-blank-identifiersassignment discards three or more results; name meaningful results or simplify the return contract

pkg/scheduler/schedule_one_test.go:3956:4

3955 podInfo := queuedPodInfoForPod(test.pod)
3956 _, _, _, err = scheduler.findNodesThatFitPod(ctx, schedFramework, framework.NewCycleState(), podInfo)
3957 if err != nil {

pkg/kubeapiserver/authorizer/config.go1

169:6exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/authorizer/config.go:169:6

168// For now, lower cases the mode name
169func GetNameForAuthorizerMode(mode string) string {
170 return strings.ToLower(mode)

pkg/proxy/conntrack/cleanup_test.go1

1:1file-length-limitfile has 568 lines; maximum is 500

pkg/proxy/conntrack/cleanup_test.go:1:1

1//go:build linux
2

pkg/proxy/iptables/proxier.go1

219:2flag-parameterboolean parameter initOnly controls function flow

pkg/proxy/iptables/proxier.go:219:2

218 healthzServer *healthcheck.ProxyHealthServer,
219 initOnly bool,
220) (*Proxier, error) {

pkg/kubeapiserver/authorizer/modes/modes.go1

1:1formatfile is not formatted

pkg/kubeapiserver/authorizer/modes/modes.go:1:1

1/*
2Copyright 2017 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/authorizer/modes/modes.go`

pkg/kubeapiserver/options/authentication.go1

490:40function-lengthfunction has 81 statements and 177 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication.go:490:40

489// an empty config if o is nil.
490func (o *BuiltInAuthenticationOptions) ToAuthenticationConfig() (kubeauthenticator.Config, error) {
491 if o == nil {

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

624:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:624:6

623
624func mustMakeEd25519KeyAndProof(t *testing.T, toBeSigned []byte) (ed25519.PrivateKey, ed25519.PublicKey, []byte, []byte) {
625 pub, priv, err := ed25519.GenerateKey(rand.Reader)

pkg/kubeapiserver/default_storage_factory_builder.go1

152:3import-shadowingidentifier resource shadows an imported package

pkg/kubeapiserver/default_storage_factory_builder.go:152:3

151 group := apiresource[0]
152 resource := apiresource[1]
153 groupResource := schema.GroupResource{Group: group, Resource: resource}

pkg/registry/core/service/storage/transaction_test.go1

53:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:53:6

52 revert: func() {
53 temp = temp - 1
54 },

pkg/proxy/ipvs/proxier.go1

1287:35inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/ipvs/proxier.go:1287:35

1286 args = append(args,
1287 "-m", "comment", "--comment", proxier.ipsetList[set.name].getComment(),
1288 "-m", "set", "--match-set", proxier.ipsetList[set.name].Name,

pkg/registry/core/pod/strategy.go1

554:12inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.FormatInt with base 10

pkg/registry/core/pod/strategy.go:554:12

553 if len(pod.Spec.Containers[i].Ports) > 0 {
554 port = fmt.Sprintf("%d", pod.Spec.Containers[i].Ports[0].ContainerPort)
555 break

pkg/kubeapiserver/options/authentication_test.go1

169:23insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:169:23

168 testSA: &ServiceAccountAuthenticationOptions{
169 Issuers: []string{"http://[::1]:namedport"},
170 },

pkg/scheduler/backend/cache/interface.go1

57:12interface-method-limitinterface has 32 methods, exceeding the configured design limit of 10

pkg/scheduler/backend/cache/interface.go:57:12

56// - If a pod wasn't added, it wouldn't be removed or updated.
57type Cache interface {
58 // NodeCount returns the number of nodes in the cache.

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go1

571:7max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go:571:7

570 qualRequestName := strings.Join([]string{request.Name, subRequest.Name}, "/")
571 if status := pl.validateDeviceClass(logger, subRequest.DeviceClassName, qualRequestName); status != nil {
572 return nil, status

pkg/proxy/ipvs/proxier.go1

242:6max-parametersfunction has 13 parameters; maximum is 8

pkg/proxy/ipvs/proxier.go:242:6

241// NewProxier returns a new single-stack IPVS proxier.
242func NewProxier(
243 ctx context.Context,

pkg/proxy/apis/config/types.go1

158:6max-public-structsfile declares more than 5 exported structs

pkg/proxy/apis/config/types.go:158:6

157// Kubernetes proxy server.
158type KubeProxyConfiguration struct {
159 metav1.TypeMeta

pkg/kubeapiserver/options/authentication.go1

823:2modifies-parameterassignment modifies parameter openAPIConfig

pkg/kubeapiserver/options/authentication.go:823:2

822
823 openAPIConfig.SecurityDefinitions = openAPIV2SecurityDefinitions
824 if openAPIV3Config != nil {

pkg/proxy/winkernel/proxier.go1

544:3modifies-value-receiverassignment modifies value receiver refCountMap

pkg/proxy/winkernel/proxier.go:544:3

543 if !exists {
544 refCountMap[hnsID] = new(uint16)
545 refCount = refCountMap[hnsID]

pkg/kubeapiserver/options/authentication_test.go1

1091:17nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/authentication_test.go:1091:17

1090func TestValidateOIDCOptions(t *testing.T) {
1091 testCases := []struct {
1092 name string

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

171:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:171:4

170 if err != nil {
171 return false, nil
172 }

pkg/proxy/ipvs/proxier.go1

321:3nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/ipvs/proxier.go:321:3

320 logger.Info("System initialized and --init-only specified")
321 return nil, nil
322 }

pkg/scheduler/backend/queue/scheduling_queue_test.go1

2403:6no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/scheduler/backend/queue/scheduling_queue_test.go:2403:6

2402 ctx, cancel := context.WithCancel(ctx)
2403 defer cancel()
2404 q := NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c), WithQueueingHintMapPerProfile(m))

pkg/proxy/node.go1

124:6no-else-after-returnremove else and unindent its body after the return

pkg/proxy/node.go:124:6

123 return nil, fmt.Errorf("timeout waiting for node %q to exist", nodeName)
124 } else {
125 return nil, fmt.Errorf("timeout waiting for PodCIDR allocation on node %q", nodeName)

pkg/scheduler/apis/config/scheme/scheme.go1

35:6no-initreplace init with explicit initialization

pkg/scheduler/apis/config/scheme/scheme.go:35:6

34
35func init() {
36 AddToScheme(Scheme)

pkg/proxy/iptables/proxier.go1

1427:2no-naked-returnreturn values must be explicit

pkg/proxy/iptables/proxier.go:1427:2

1426 }
1427 return
1428}

pkg/kubeapiserver/options/authentication.go2

82:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/options/authentication.go:82:5

81// Exported as a variable so that it can be overridden in integration tests.
82var UpdateAuthenticationConfigTimeout = time.Minute
83
590:8optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:590:8

589 switch {
590 case ret.AuthenticationConfig.Anonymous != nil && o.Anonymous.FlagsSet:
591 // Flags and config file are mutually exclusive

pkg/registry/rbac/clusterrole/strategy.go1

67:2overwritten-before-usethis value of oldClusterRole is overwritten before use

pkg/registry/rbac/clusterrole/strategy.go:67:2

66 newClusterRole := obj.(*rbac.ClusterRole)
67 oldClusterRole := old.(*rbac.ClusterRole)
68

pkg/kubeapiserver/authorizer/modes/modes.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/authorizer/modes/modes.go:17:9

16
17package modes
18

pkg/registry/core/node/rest/proxy.go1

17:9package-directory-mismatchpackage node does not match directory rest

pkg/registry/core/node/rest/proxy.go:17:9

16
17package node
18

pkg/registry/core/pod/storage/storage_test.go1

402:62possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/registry/core/pod/storage/storage_test.go:402:62

401 if location.Host != tc.location {
402 t.Errorf("Expected %v, but got %v", tc.location, location.Host)
403 }

pkg/proxy/healthcheck/service_health.go1

148:10range-value-addresstaking the address of range value nsn can be misleading

pkg/proxy/healthcheck/service_health.go:148:10

147
148 svc := &hcInstance{nsn: nsn, port: port}
149 err := svc.listenAndServeAll(hcs)

pkg/registry/core/componentstatus/rest.go1

182:7receiver-namingreceiver name r is inconsistent with rs

pkg/registry/core/componentstatus/rest.go:182:7

181// ShortNames implements the ShortNamesProvider interface. Returns a list of short names for a resource.
182func (r *REST) ShortNames() []string {
183 return []string{"cs"}

pkg/proxy/iptables/proxier_test.go1

183:3redefines-builtin-ididentifier error shadows a predeclared identifier

pkg/proxy/iptables/proxier_test.go:183:3

182 output map[string][]string
183 error string
184 }{

pkg/proxy/apis/config/v1alpha1/defaults_test.go1

36:11redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/apis/config/v1alpha1/defaults_test.go:36:11

35 ctMaxPerCore := int32(32768)
36 ctMin := int32(131072)
37 testCases := []struct {

pkg/proxy/endpointschangetracker.go1

23:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/endpointschangetracker.go:23:2

22
23 v1 "k8s.io/api/core/v1"
24 discovery "k8s.io/api/discovery/v1"

pkg/kubeapiserver/options/authorization.go1

261:3single-case-switchswitch with one case can be replaced by an if statement

pkg/kubeapiserver/options/authorization.go:261:3

260 for _, mode := range o.Modes {
261 switch mode {
262 case authzmodes.ModeWebhook:

pkg/proxy/ipvs/ipset/testing/fake.go1

138:2slice-preallocationpreallocate res with capacity len(range source) before appending once per iteration

pkg/proxy/ipvs/ipset/testing/fake.go:138:2

137func (f *FakeIPSet) ListSets() ([]string, error) {
138 res := []string{}
139 for set := range f.Sets {

pkg/kubeapiserver/options/authentication.go1

526:3task-commentTODO comment should be resolved or linked to an owned work item

pkg/kubeapiserver/options/authentication.go:526:3

525 // all known signing algs are allowed when using authentication config
526 // TODO: what we really want to express is 'any alg is fine as long it matches a public key'
527 ret.OIDCSigningAlgs = oidc.AllValidSigningAlgorithms()

pkg/kubeapiserver/options/authentication_test.go1

58:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/authentication_test.go:58:6

57
58func TestAuthenticationValidate(t *testing.T) {
59 testCases := []struct {

pkg/kubeapiserver/options/authentication.go1

871:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/options/authentication.go:871:1

870
871var (
872 cfgScheme = runtime.NewScheme()

pkg/proxy/ipvs/proxier_test.go1

1909:22unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/ipvs/proxier_test.go:1909:22

1908 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf, addrs)
1909 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf1, addrs1)
1910 fp.nodePortAddresses = proxyutil.NewNodePortAddresses(v1.IPv4Protocol, []string{"100.101.102.0/24"})

pkg/registry/admissionregistration/validatingadmissionpolicy/strategy.go1

48:109unexported-returnexported function returns an unexported type

pkg/registry/admissionregistration/validatingadmissionpolicy/strategy.go:48:109

47// NewStrategy is the default logic that applies when creating and updating validatingAdmissionPolicy objects.
48func NewStrategy(authorizer authorizer.UnconditionalAuthorizer, resourceResolver resolver.ResourceResolver) *validatingAdmissionPolicyStrategy {
49 return &validatingAdmissionPolicyStrategy{

pkg/proxy/config/config_test.go1

72:46unused-parameterparameter oldService is unused

pkg/proxy/config/config_test.go:72:46

71
72func (h *ServiceHandlerMock) OnServiceUpdate(oldService, service *v1.Service) {
73 h.lock.Lock()

pkg/proxy/apis/config/types.go1

298:7unused-receiverreceiver m is unused

pkg/proxy/apis/config/types.go:298:7

297
298func (m *LocalMode) Type() string {
299 return "LocalMode"

pkg/proxy/config/config.go1

147:61use-anyuse any instead of interface{}

pkg/proxy/config/config.go:147:61

146
147func (c *EndpointSliceConfig) handleDeleteEndpointSlice(obj interface{}) {
148 endpointSlice, ok := obj.(*discoveryv1.EndpointSlice)

pkg/kubeapiserver/authorizer/reload.go1

145:22use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/authorizer/reload.go:145:22

144 if r.abacAuthorizer == nil {
145 return nil, nil, fmt.Errorf("authorizer type ABAC is not allowed if it was not enabled at initial server startup")
146 }

pkg/proxy/iptables/proxier_test.go1

672:3use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/iptables/proxier_test.go:672:3

671 table := &dump.Tables[t]
672 sort.Slice(table.Chains, func(i, j int) bool {
673 switch {

pkg/proxy/endpointschangetracker_test.go1

355:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:355:2

354 }
355 multipleSubsetsMultiplePortsLocal_s2 := func(eps *discovery.EndpointSlice) {
356 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/admission_test.go1

53:33add-constantstring literal "ServiceAccount" appears more than twice; define a constant

pkg/kubeapiserver/options/admission_test.go:53:33

52 options = NewAdmissionOptions()
53 options.PluginNames = []string{"ServiceAccount"}
54 if errs := options.Validate(); len(errs) > 0 {

pkg/registry/core/namespace/storage/storage_test.go1

616:7boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/registry/core/namespace/storage/storage_test.go:616:7

615 for _, f := range ns.Finalizers {
616 if test.remainingFinalizers[f] != true {
617 t.Errorf("%s: unexpected finalizer %s", test.name, f)

pkg/kubeapiserver/options/authentication.go1

340:40cognitive-complexityfunction has cognitive complexity 9; maximum is 7

pkg/kubeapiserver/options/authentication.go:340:40

339// AddFlags returns flags of authentication for a API Server
340func (o *BuiltInAuthenticationOptions) AddFlags(fs *pflag.FlagSet) {
341 if o == nil {

pkg/proxy/node.go1

74:6confusing-namingname newNodeManager differs from NewNodeManager only by capitalization

pkg/proxy/node.go:74:6

73// newNodeManager implements NewNodeManager with configurable exit function, poll interval and timeouts.
74func newNodeManager(ctx context.Context, client clientset.Interface, resyncInterval time.Duration,
75 nodeName string, watchPodCIDRs bool, exitFunc func(int),

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go1

3983:62confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go:3983:62

3982
3983func (tc *testContext) listAssumedClaims() ([]metav1.Object, []metav1.Object) {
3984 var assumedClaims []metav1.Object

pkg/proxy/util/localdetector.go1

73:6constructor-interface-returnNewNoOpLocalDetector returns interface LocalTrafficDetector although its concrete result is consistently *detectLocal; return the concrete type

pkg/proxy/util/localdetector.go:73:6

72// NewNoOpLocalDetector returns a no-op implementation of LocalTrafficDetector.
73func NewNoOpLocalDetector() LocalTrafficDetector {
74 return &detectLocal{}

pkg/kubeapiserver/options/authentication_test.go1

1612:6cyclomatic-complexityfunction complexity is 18; maximum is 10

pkg/kubeapiserver/options/authentication_test.go:1612:6

1611
1612func TestToAuthenticationConfigForServiceAccount(t *testing.T) {
1613

pkg/registry/batch/job/storage/storage_test.go1

229:41deprecated-api-usagek8s.io/apimachinery/pkg/apis/meta/v1.OrphanDependents is deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. +optional

pkg/registry/batch/job/storage/storage_test.go:229:41

228 expectWarning: false,
229 deleteOptions: &metav1.DeleteOptions{OrphanDependents: &orphanDependents},
230 requestInfo: &genericapirequest.RequestInfo{APIGroup: "batch", APIVersion: "v1"},

pkg/proxy/config/config.go1

376:28discarded-error-resulterror result returned by serviceCIDRInformer.Informer().AddEventHandlerWithResyncPeriod is discarded

pkg/proxy/config/config.go:376:28

375
376 handlerRegistration, _ := serviceCIDRInformer.Informer().AddEventHandlerWithResyncPeriod(
377 cache.ResourceEventHandlerFuncs{

pkg/kubeapiserver/authorizer/config.go1

167:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/config.go:167:1

166
167// GetNameForAuthorizerMode returns the name to be set for the mode in AuthorizationConfiguration
168// For now, lower cases the mode name

pkg/scheduler/backend/cache/cache_test.go1

3026:3early-returninvert the condition and return early to reduce nesting

pkg/scheduler/backend/cache/cache_test.go:3026:3

3025 for _, nodeName := range nodesList {
3026 if n := snapshot.nodeInfoMap[nodeName]; n != nil {
3027 expectedNodeInfoList = append(expectedNodeInfoList, n)

pkg/kubeapiserver/options/authentication_test.go1

1235:14error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/authentication_test.go:1235:14

1234 if len(errs) > 0 && (!strings.Contains(utilerrors.NewAggregate(errs).Error(), tt.expectErr) || tt.expectErr == "") {
1235 t.Errorf("Got err: %v, Expected err: %s", errs, tt.expectErr)
1236 }

pkg/scheduler/schedule_one_test.go1

4565:4excessive-blank-identifiersassignment discards three or more results; name meaningful results or simplify the return contract

pkg/scheduler/schedule_one_test.go:4565:4

4564 podInfo := queuedPodInfoForPod(test.pod)
4565 _, _, _, err = sched.findNodesThatFitPod(ctx, fwk, framework.NewCycleState(), podInfo)
4566 if err != nil {

pkg/kubeapiserver/authorizer/config.go1

173:6exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/authorizer/config.go:173:6

172
173func LoadAndValidateFile(configFile string, compiler authorizationcel.Compiler, requireNonWebhookTypes sets.Set[authzconfig.AuthorizerType]) (*authzconfig.AuthorizationConfiguration, string, error) {
174 data, err := os.ReadFile(configFile)

pkg/proxy/endpointschangetracker_test.go1

1:1file-length-limitfile has 1651 lines; maximum is 500

pkg/proxy/endpointschangetracker_test.go:1:1

1/*
2Copyright 2017 The Kubernetes Authors.

pkg/proxy/iptables/proxier.go1

434:40flag-parameterboolean parameter value controls function flow

pkg/proxy/iptables/proxier.go:434:40

433
434func (proxier *Proxier) setInitialized(value bool) {
435 var initialized int32

pkg/kubeapiserver/authorizer/modes/modes_test.go1

1:1formatfile is not formatted

pkg/kubeapiserver/authorizer/modes/modes_test.go:1:1

1/*
2Copyright 2017 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/authorizer/modes/modes_test.go`

pkg/kubeapiserver/options/authentication.go1

670:40function-lengthfunction has 82 statements and 150 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication.go:670:40

669// The input context controls the lifecycle of background goroutines started to reload the authentication config file.
670func (o *BuiltInAuthenticationOptions) ApplyTo(
671 ctx context.Context,

pkg/registry/certificates/podcertificaterequest/strategy_test.go1

484:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/certificates/podcertificaterequest/strategy_test.go:484:6

483
484func mustMakeEd25519KeyAndProof(t *testing.T, toBeSigned []byte) (ed25519.PrivateKey, ed25519.PublicKey, []byte, []byte) {
485 pub, priv, err := ed25519.GenerateKey(rand.Reader)

pkg/kubeapiserver/options/admission.go1

117:2import-shadowingidentifier informers shadows an imported package

pkg/kubeapiserver/options/admission.go:117:2

116 c *server.Config,
117 informers informers.SharedInformerFactory,
118 kubeClient kubernetes.Interface,

pkg/registry/core/service/storage/transaction_test.go1

79:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:79:6

78 commit: func() {
79 temp = temp + 1
80 },

pkg/proxy/ipvs/proxier.go1

1288:33inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/ipvs/proxier.go:1288:33

1287 "-m", "comment", "--comment", proxier.ipsetList[set.name].getComment(),
1288 "-m", "set", "--match-set", proxier.ipsetList[set.name].Name,
1289 set.matchType,

pkg/registry/core/service/storage/storage_test.go1

904:7inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/registry/core/service/storage/storage_test.go:904:7

903 if ok {
904 s = fmt.Sprintf("%d", line)
905 } else {

pkg/kubeapiserver/options/authentication_test.go1

184:24insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:184:24

183 KeyFiles: []string{"cert", "key"},
184 Issuers: []string{"http://foo.bar.com"},
185 JWKSURI: "https://host:port",

pkg/scheduler/backend/queue/active_queue.go1

36:19interface-method-limitinterface has 20 methods, exceeding the configured design limit of 10

pkg/scheduler/backend/queue/active_queue.go:36:19

35// Its methods take the lock inside.
36type activeQueuer interface {
37 underLock(func(unlockedActiveQ unlockedActiveQueuer))

pkg/scheduler/framework/plugins/dynamicresources/nodeallocatabledynamicresources.go1

160:7max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/plugins/dynamicresources/nodeallocatabledynamicresources.go:160:7

159 quantity = consumed.DeepCopy()
160 if resourceMap.AllocationMultiplier != nil {
161 qDec := quantity.AsDec()

pkg/proxy/nftables/proxier.go1

202:6max-parametersfunction has 9 parameters; maximum is 8

pkg/proxy/nftables/proxier.go:202:6

201// NewProxier returns a new single-stack NFTables proxier.
202func NewProxier(ctx context.Context,
203 config *kubeproxyconfig.KubeProxyConfiguration,

pkg/registry/core/pod/storage/storage.go1

375:6max-public-structsfile declares more than 5 exported structs

pkg/registry/core/pod/storage/storage.go:375:6

374// EphemeralContainersREST implements the REST endpoint for adding EphemeralContainers
375type EphemeralContainersREST struct {
376 store *genericregistry.Store

pkg/kubeapiserver/options/authentication.go1

825:3modifies-parameterassignment modifies parameter openAPIV3Config

pkg/kubeapiserver/options/authentication.go:825:3

824 if openAPIV3Config != nil {
825 openAPIV3Config.SecuritySchemes = openAPIV3SecuritySchemes
826 }

pkg/registry/core/pod/storage/storage_test.go1

155:2modifies-value-receiverassignment modifies value receiver f

pkg/registry/core/pod/storage/storage_test.go:155:2

154func (f FailDeletionStorage) Delete(_ context.Context, key string, _ runtime.Object, _ *apiserverstorage.Preconditions, _ apiserverstorage.ValidateObjectFunc, _ runtime.Object, _ apiserverstorage.DeleteOptions) error {
155 *f.Called = true
156 return apiserverstorage.NewKeyNotFoundError(key, 0)

pkg/kubeapiserver/options/authentication_test.go1

1248:17nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/authentication_test.go:1248:17

1247func TestLoadAuthenticationConfig(t *testing.T) {
1248 testCases := []struct {
1249 name string

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

230:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:230:4

229 if err != nil {
230 return false, nil
231 }

pkg/proxy/ipvs/proxier_test.go1

89:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/ipvs/proxier_test.go:89:2

88func (f *fakeIpvs) GetVirtualServer(*utilipvs.VirtualServer) (*utilipvs.VirtualServer, error) {
89 return nil, nil
90}

pkg/scheduler/eventhandlers.go1

291:4no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/scheduler/eventhandlers.go:291:4

290 if evt.Label() != framework.EventUnscheduledPodUpdate.Label() {
291 defer metrics.EventHandlingLatency.ObserveSince(start, evt.Label())()
292 }

pkg/proxy/util/nfacct/nfacct_linux.go1

101:4no-else-after-returnremove else and unindent its body after the return

pkg/proxy/util/nfacct/nfacct_linux.go:101:4

100 return handleError(r.Add(name))
101 } else if err != nil {
102 return handleError(err)

pkg/scheduler/apis/config/v1/register.go1

37:6no-initreplace init with explicit initialization

pkg/scheduler/apis/config/v1/register.go:37:6

36
37func init() {
38 // We only register manually written functions here. The registration of the

pkg/proxy/ipvs/proxier.go1

665:3no-naked-returnreturn values must be explicit

pkg/proxy/ipvs/proxier.go:665:3

664 proxier.logger.V(2).Info("Not syncing ipvs rules until Services and Endpoints have been received from master")
665 return
666 }

pkg/kubeapiserver/options/authentication.go2

872:2no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/options/authentication.go:872:2

871var (
872 cfgScheme = runtime.NewScheme()
873 codecs = serializer.NewCodecFactory(cfgScheme, serializer.EnableStrict)
616:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:616:6

615 if o.ServiceAccounts != nil {
616 if len(o.ServiceAccounts.Issuers) != 0 && len(o.APIAudiences) == 0 {
617 ret.APIAudiences = authenticator.Audiences(o.ServiceAccounts.Issuers)

pkg/registry/rbac/clusterrolebinding/strategy.go1

65:2overwritten-before-usethis value of newClusterRoleBinding is overwritten before use

pkg/registry/rbac/clusterrolebinding/strategy.go:65:2

64func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
65 newClusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
66 oldClusterRoleBinding := old.(*rbac.ClusterRoleBinding)

pkg/kubeapiserver/authorizer/reload.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/authorizer/reload.go:17:9

16
17package authorizer
18

pkg/scheduler/framework/autoscaler_contract/framework_contract_test.go1

21:9package-directory-mismatchpackage contract does not match directory autoscaler_contract

pkg/scheduler/framework/autoscaler_contract/framework_contract_test.go:21:9

20
21package contract
22

pkg/scheduler/backend/queue/scheduling_queue_test.go1

5563:18possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/backend/queue/scheduling_queue_test.go:5563:18

5562
5563 if !cmp.Equal(pInfo.Pod, tt.expectedPod) {
5564 t.Errorf("Expected pod=%v, but got pod=%v", tt.expectedPod, pInfo.Pod)

pkg/proxy/healthcheck/service_health.go1

148:10range-value-addresstaking the address of range value port can be misleading

pkg/proxy/healthcheck/service_health.go:148:10

147
148 svc := &hcInstance{nsn: nsn, port: port}
149 err := svc.listenAndServeAll(hcs)

pkg/registry/core/namespace/storage/storage.go1

289:7receiver-namingreceiver name e is inconsistent with r

pkg/registry/core/namespace/storage/storage.go:289:7

288
289func (e *REST) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
290 return e.store.ConvertToTable(ctx, object, tableOptions)

pkg/proxy/iptables/proxier_test.go1

506:3redefines-builtin-ididentifier error shadows a predeclared identifier

pkg/proxy/iptables/proxier_test.go:506:3

505 input string
506 error string
507 }{

pkg/proxy/apis/config/validation/validation_test.go1

400:106redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/apis/config/validation/validation_test.go:400:106

399 },
400 expectedErrs: field.ErrorList{field.Invalid(newPath.Child("KubeProxyLinuxConfiguration.OOMScoreAdj"), int32(-1001), "must be within the range [-1000, 1000]")},
401 },

pkg/proxy/endpointschangetracker_test.go1

25:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/endpointschangetracker_test.go:25:2

24
25 v1 "k8s.io/api/core/v1"
26 discovery "k8s.io/api/discovery/v1"

pkg/proxy/apis/config/v1alpha1/conversion.go1

35:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/apis/config/v1alpha1/conversion.go:35:2

34 out.OOMScoreAdj = in.Linux.OOMScoreAdj
35 switch in.Mode {
36 case kubeproxyconfig.ProxyModeNFTables:

pkg/proxy/ipvs/netlink_linux.go1

122:6slice-preallocationpreallocate ips with capacity len(range source) before appending once per iteration

pkg/proxy/ipvs/netlink_linux.go:122:6

121 }
122 var ips []string
123 for _, addr := range addrs {

pkg/kubeapiserver/options/authentication.go1

766:5task-commentTODO comment should be resolved or linked to an owned work item

pkg/kubeapiserver/options/authentication.go:766:5

765 func() {
766 // TODO collapse onto shared logic with DynamicEncryptionConfigContent controller
767

pkg/kubeapiserver/options/authentication_test.go2

282:24test-parallelismconsider calling t.Parallel() when this subtest begins

pkg/kubeapiserver/options/authentication_test.go:282:24

281 for _, testcase := range testCases {
282 t.Run(testcase.name, func(t *testing.T) {
283 options := NewBuiltInAuthenticationOptions()
1767:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/options/authentication_test.go:1767:1

1766
1767type dummyPublicKeyGetter struct {
1768}

pkg/proxy/ipvs/proxier_test.go1

1996:22unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/ipvs/proxier_test.go:1996:22

1995 addrs1 := []net.Addr{&net.IPNet{IP: netutils.ParseIPSloppy("2001:db8::"), Mask: net.CIDRMask(64, 128)}}
1996 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf, addrs)
1997 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf1, addrs1)

pkg/registry/admissionregistration/validatingadmissionpolicy/strategy.go1

205:75unexported-returnexported function returns an unexported type

pkg/registry/admissionregistration/validatingadmissionpolicy/strategy.go:205:75

204// NewStatusStrategy creates a strategy for operating the status object.
205func NewStatusStrategy(policyStrategy *validatingAdmissionPolicyStrategy) *validatingAdmissionPolicyStatusStrategy {
206 return &validatingAdmissionPolicyStatusStrategy{validatingAdmissionPolicyStrategy: policyStrategy}

pkg/proxy/config/config_test.go1

252:58unused-parameterparameter oldSlice is unused

pkg/proxy/config/config_test.go:252:58

251
252func (h *EndpointSliceHandlerMock) OnEndpointSliceUpdate(oldSlice, slice *discoveryv1.EndpointSlice) {
253 h.lock.Lock()

pkg/proxy/conntrack/sysctls.go1

186:7unused-receiverreceiver rct is unused

pkg/proxy/conntrack/sysctls.go:186:7

185
186func (rct realConntrackConfigurer) setIntSysCtl(ctx context.Context, name string, value int) error {
187 logger := klog.FromContext(ctx)

pkg/proxy/config/config.go1

212:46use-anyuse any instead of interface{}

pkg/proxy/config/config.go:212:46

211
212func (c *ServiceConfig) handleAddService(obj interface{}) {
213 service, ok := obj.(*v1.Service)

pkg/kubeapiserver/authorizer/reload.go1

201:22use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/authorizer/reload.go:201:22

200 if r.rbacAuthorizer == nil {
201 return nil, nil, fmt.Errorf("authorizer type RBAC is not allowed if it was not enabled at initial server startup")
202 }

pkg/proxy/iptables/proxier_test.go1

703:3use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/iptables/proxier_test.go:703:3

702 if chain != nil {
703 sort.SliceStable(chain.Rules, func(i, j int) bool {
704 return orderByCommentServiceName(chain.Rules[i], chain.Rules[j])

pkg/proxy/endpointschangetracker_test.go1

365:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:365:2

364 }
365 multipleSubsetsIPsPorts1_s1 := func(eps *discovery.EndpointSlice) {
366 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/admission_test.go1

80:31add-constantstring literal "one" appears more than twice; define a constant

pkg/kubeapiserver/options/admission_test.go:80:31

79 name: "choose one",
80 all: []string{"one", "two"},
81 enabled: []string{"one"},

pkg/registry/core/service/storage/storage_test.go1

11806:7boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/registry/core/service/storage/storage_test.go:11806:7

11805 location, _, err := redirector.ResourceLocation(ctx, tc.query)
11806 if tc.err == false && err != nil {
11807 t.Fatalf("unexpected error: %v", err)

pkg/kubeapiserver/options/authentication.go1

490:40cognitive-complexityfunction has cognitive complexity 66; maximum is 7

pkg/kubeapiserver/options/authentication.go:490:40

489// an empty config if o is nil.
490func (o *BuiltInAuthenticationOptions) ToAuthenticationConfig() (kubeauthenticator.Config, error) {
491 if o == nil {

pkg/registry/core/service/ipallocator/bitmap.go1

171:17confusing-namingname allocate differs from Allocate only by capitalization

pkg/registry/core/service/ipallocator/bitmap.go:171:17

170
171func (r *Range) allocate(ip net.IP, dryRun bool) error {
172 label := r.CIDR()

pkg/scheduler/framework/plugins/dynamicresources/extendeddynamicresources.go1

322:90confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/dynamicresources/extendeddynamicresources.go:322:90

321
322func partitionContainerIndices(containers []v1.Container, numInitContainers int) ([]int, []int) {
323 longLivedContainerIndices := make([]int, 0, len(containers))

pkg/proxy/util/localdetector.go1

80:6constructor-interface-returnNewDetectLocalByCIDR returns interface LocalTrafficDetector although its concrete result is consistently *detectLocal; return the concrete type

pkg/proxy/util/localdetector.go:80:6

79// assumed to be valid.
80func NewDetectLocalByCIDR(cidr string) LocalTrafficDetector {
81 nftFamily := "ip"

pkg/kubeapiserver/options/authorization.go1

97:39cyclomatic-complexityfunction complexity is 20; maximum is 10

pkg/kubeapiserver/options/authorization.go:97:39

96// Validate checks invalid config combination
97func (o *BuiltInAuthorizationOptions) Validate() []error {
98 if o == nil {

pkg/registry/batch/job/storage/storage_test.go1

268:41deprecated-api-usagek8s.io/apimachinery/pkg/apis/meta/v1.OrphanDependents is deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both. +optional

pkg/registry/batch/job/storage/storage_test.go:268:41

267 expectWarning: false,
268 deleteOptions: &metav1.DeleteOptions{OrphanDependents: &orphanDependents},
269 listOptions: &internalversion.ListOptions{},

pkg/proxy/config/config.go1

479:28discarded-error-resulterror result returned by nodeInformer.Informer().AddEventHandlerWithResyncPeriod is discarded

pkg/proxy/config/config.go:479:28

478
479 handlerRegistration, _ := nodeInformer.Informer().AddEventHandlerWithResyncPeriod(
480 cache.ResourceEventHandlerFuncs{

pkg/kubeapiserver/authorizer/modes/modes.go1

22:2doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/modes/modes.go:22:2

21const (
22 // ModeAlwaysAllow is the mode to set all requests as authorized
23 ModeAlwaysAllow string = "AlwaysAllow"

pkg/scheduler/extender.go1

298:4early-returninvert the condition and return early to reduce nesting

pkg/scheduler/extender.go:298:4

297 for i, nodeName := range *result.NodeNames {
298 if n, ok := fromNodeName[nodeName]; ok {
299 nodeResult[i] = n

pkg/kubeapiserver/options/authentication_test.go1

1238:14error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/authentication_test.go:1238:14

1237 if len(errs) == 0 && len(tt.expectErr) != 0 {
1238 t.Errorf("Got err nil, Expected err: %s", tt.expectErr)
1239 }

pkg/kubeapiserver/authorizer/config.go1

185:6exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/authorizer/config.go:185:6

184
185func LoadAndValidateData(data []byte, compiler authorizationcel.Compiler, requireNonWebhookTypes sets.Set[authzconfig.AuthorizerType]) (*authzconfig.AuthorizationConfiguration, error) {
186 // load the file and check for errors

pkg/proxy/endpointslicecache_test.go1

1:1file-length-limitfile has 707 lines; maximum is 500

pkg/proxy/endpointslicecache_test.go:1:1

1/*
2Copyright 2019 The Kubernetes Authors.

pkg/proxy/iptables/proxier_test.go1

1087:55flag-parameterboolean parameter checkConsistency controls function flow

pkg/proxy/iptables/proxier_test.go:1087:55

1086// disabled by passing false for checkConsistency if you are passing a partial set of rules.
1087func assertIPTablesRulesEqual(t *testing.T, line int, checkConsistency bool, expected, result string) {
1088 expected = strings.TrimLeft(expected, " \t\n")

pkg/kubeapiserver/authorizer/reload.go1

1:1formatfile is not formatted

pkg/kubeapiserver/authorizer/reload.go:1:1

1/*
2Copyright 2024 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/authorizer/reload.go`

pkg/kubeapiserver/options/authentication_test.go1

58:6function-lengthfunction has 22 statements and 255 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:58:6

57
58func TestAuthenticationValidate(t *testing.T) {
59 testCases := []struct {

pkg/registry/core/namespace/storage/storage.go1

60:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/core/namespace/storage/storage.go:60:6

59// NewREST returns a RESTStorage object that will work against namespaces.
60func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *FinalizeREST, error) {
61 store := &genericregistry.Store{

pkg/kubeapiserver/options/authentication.go1

746:2import-shadowingidentifier authenticator shadows an imported package

pkg/kubeapiserver/options/authentication.go:746:2

745 // var openAPIV3SecuritySchemes spec3.SecuritySchemes
746 authenticator, updateAuthenticationConfig, openAPIV2SecurityDefinitions, openAPIV3SecuritySchemes, err := authenticatorConfig.New(ctx)
747 if err != nil {

pkg/registry/core/service/storage/transaction_test.go1

82:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:82:6

81 revert: func() {
82 temp = temp - 1
83 },

pkg/proxy/ipvs/testing/fake.go1

90:3inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/proxy/ipvs/testing/fake.go:90:3

89 // create dummy interface if devName is not found in localAddress map
90 h.localAddresses[devName] = make([]string, 0)
91 return false, nil

pkg/scheduler/backend/queue/scheduling_queue_test.go1

6012:50inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/scheduler/backend/queue/scheduling_queue_test.go:6012:50

6011 newPod := currentPod.DeepCopy()
6012 newPod.Annotations = map[string]string{"ver": fmt.Sprintf("%d", iter)}
6013 // Update is atomic

pkg/kubeapiserver/options/authentication_test.go1

200:24insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:200:24

199 KeyFiles: []string{"cert", "key"},
200 Issuers: []string{"http://foo.bar.com"},
201 JWKSURI: "http://baz.com",

pkg/scheduler/backend/queue/backoff_queue.go1

42:20interface-method-limitinterface has 12 methods, exceeding the configured design limit of 10

pkg/scheduler/backend/queue/backoff_queue.go:42:20

41// Its methods that relies on the queues, take the lock inside.
42type backoffQueuer interface {
43 // isEntityBackingoff returns true if an entity is still waiting for its backoff timer.

pkg/scheduler/framework/preemption/executor_test.go1

771:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/preemption/executor_test.go:771:8

770 if tt.expectedStatus == nil {
771 if status != nil {
772 t.Errorf("expect nil status, but got %v", status)

pkg/proxy/node.go1

74:6max-parametersfunction has 9 parameters; maximum is 8

pkg/proxy/node.go:74:6

73// newNodeManager implements NewNodeManager with configurable exit function, poll interval and timeouts.
74func newNodeManager(ctx context.Context, client clientset.Interface, resyncInterval time.Duration,
75 nodeName string, watchPodCIDRs bool, exitFunc func(int),

pkg/registry/core/pod/storage/storage.go1

405:6max-public-structsfile declares more than 5 exported structs

pkg/registry/core/pod/storage/storage.go:405:6

404// ResizeREST implements the REST endpoint for resizing Pod containers.
405type ResizeREST struct {
406 store *genericregistry.Store

pkg/proxy/apis/config/v1alpha1/conversion.go1

32:2modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:32:2

31 }
32 out.WindowsRunAsService = in.Windows.RunAsService
33 out.Conntrack = v1alpha1.KubeProxyConntrackConfiguration(in.Linux.Conntrack)

pkg/registry/rbac/validation/rule_test.go1

52:39modifies-value-receiverassignment modifies value receiver b

pkg/registry/rbac/validation/rule_test.go:52:39

51func (b byHash) Less(i, j int) bool { return hashOf(b[i]) < hashOf(b[j]) }
52func (b byHash) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
53

pkg/kubeapiserver/options/authentication_test.go1

1651:17nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/authentication_test.go:1651:17

1650
1651 testCases := []struct {
1652 desc string

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

258:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:258:4

257 if err != nil {
258 return false, nil
259 }

pkg/proxy/nftables/proxier.go1

127:3nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/nftables/proxier.go:127:3

126 if initOnly {
127 return nil, nil
128 }

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go1

1364:4no-defer-in-loopdefer inside a loop runs at function exit, not iteration exit

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go:1364:4

1363 }
1364 defer func() {
1365 if retStatus.IsSuccess() && successCleanup != nil {

pkg/proxy/util/nfacct/nfacct_linux.go1

103:4no-else-after-returnremove else and unindent its body after the return

pkg/proxy/util/nfacct/nfacct_linux.go:103:4

102 return handleError(err)
103 } else {
104 return ErrUnexpected

pkg/scheduler/backend/cache/cache_test.go1

57:6no-initreplace init with explicit initialization

pkg/scheduler/backend/cache/cache_test.go:57:6

56
57func init() {
58 metrics.Register()

pkg/proxy/ipvs/proxier.go1

713:3no-naked-returnreturn values must be explicit

pkg/proxy/ipvs/proxier.go:713:3

712 proxier.logger.Error(err, "Failed to create dummy interface", "interface", defaultDummyDevice)
713 return
714 }

pkg/kubeapiserver/options/authentication.go2

873:2no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/options/authentication.go:873:2

872 cfgScheme = runtime.NewScheme()
873 codecs = serializer.NewCodecFactory(cfgScheme, serializer.EnableStrict)
874)
621:8optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:621:8

620 switch {
621 case len(o.ServiceAccounts.KeyFiles) > 0 && o.ServiceAccounts.ExternalPublicKeysGetter != nil:
622 return kubeauthenticator.Config{}, fmt.Errorf("cannot set mutually exclusive flags `--service-account-key-file` and `--service-account-signing-endpoint` at the same time")

pkg/registry/rbac/clusterrolebinding/strategy.go1

66:2overwritten-before-usethis value of oldClusterRoleBinding is overwritten before use

pkg/registry/rbac/clusterrolebinding/strategy.go:66:2

65 newClusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
66 oldClusterRoleBinding := old.(*rbac.ClusterRoleBinding)
67

pkg/kubeapiserver/default_storage_factory_builder.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/default_storage_factory_builder.go:17:9

16
17package kubeapiserver
18

pkg/scheduler/framework/autoscaler_contract/lister_contract_test.go1

21:9package-directory-mismatchpackage contract does not match directory autoscaler_contract

pkg/scheduler/framework/autoscaler_contract/lister_contract_test.go:21:9

20
21package contract
22

pkg/scheduler/backend/queue/scheduling_queue_test.go1

5564:65possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/backend/queue/scheduling_queue_test.go:5564:65

5563 if !cmp.Equal(pInfo.Pod, tt.expectedPod) {
5564 t.Errorf("Expected pod=%v, but got pod=%v", tt.expectedPod, pInfo.Pod)
5565 }

pkg/proxy/healthcheck/service_health.go1

156:6range-value-addresstaking the address of range value nsn can be misleading

pkg/proxy/healthcheck/service_health.go:156:6

155 hcs.recorder.Eventf(
156 &v1.ObjectReference{
157 APIVersion: "v1",

pkg/registry/rbac/clusterrole/policybased/storage.go1

73:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/clusterrole/policybased/storage.go:73:7

72
73func (s *Storage) Create(ctx context.Context, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
74 if rbacregistry.EscalationAllowed(ctx) || rbacregistry.RoleEscalationAuthorized(ctx, s.authorizer) {

pkg/proxy/iptables/proxier_test.go1

742:3redefines-builtin-ididentifier error shadows a predeclared identifier

pkg/proxy/iptables/proxier_test.go:742:3

741 output string
742 error string
743 }{

pkg/proxy/apis/config/validation/validation_test.go1

414:106redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/apis/config/validation/validation_test.go:414:106

413 },
414 expectedErrs: field.ErrorList{field.Invalid(newPath.Child("KubeProxyLinuxConfiguration.OOMScoreAdj"), int32(1001), "must be within the range [-1000, 1000]")},
415 },

pkg/proxy/endpointslicecache_test.go1

25:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/endpointslicecache_test.go:25:2

24
25 v1 "k8s.io/api/core/v1"
26 discovery "k8s.io/api/discovery/v1"

pkg/proxy/apis/config/v1alpha1/conversion.go1

42:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/apis/config/v1alpha1/conversion.go:42:2

41
42 switch in.Mode {
43 case kubeproxyconfig.ProxyModeIPVS:

pkg/proxy/ipvs/proxier_test.go1

3640:3slice-preallocationpreallocate expectedEntries with capacity len(range source) before appending once per iteration

pkg/proxy/ipvs/proxier_test.go:3640:3

3639 }
3640 expectedEntries := []string{}
3641 for _, entry := range entries {

pkg/proxy/apis/config/validation/validation_test.go1

500:2task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/apis/config/validation/validation_test.go:500:2

499func testValidateProxyModeWindows(t *testing.T) {
500 // TODO: remove skip once the test has been fixed.
501 if runtime.GOOS == "windows" {

pkg/kubeapiserver/options/authentication_test.go1

314:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/authentication_test.go:314:6

313
314func TestToAuthenticationConfig(t *testing.T) {
315 testOptions := &BuiltInAuthenticationOptions{

pkg/kubeapiserver/options/options.go1

33:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/kubeapiserver/options/options.go:33:1

32// DefaultEtcdPathPrefix is the default key prefix of etcd for API Server
33const DefaultEtcdPathPrefix = "/registry"
34

pkg/proxy/ipvs/proxier_test.go1

1997:22unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/ipvs/proxier_test.go:1997:22

1996 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf, addrs)
1997 fp.networkInterfacer.(*proxyutiltest.FakeNetwork).AddInterfaceAddr(&itf1, addrs1)
1998 fp.nodePortAddresses = proxyutil.NewNodePortAddresses(v1.IPv4Protocol, []string{"100.101.102.0/24"})

pkg/registry/admissionregistration/validatingadmissionpolicybinding/strategy.go1

57:136unexported-returnexported function returns an unexported type

pkg/registry/admissionregistration/validatingadmissionpolicybinding/strategy.go:57:136

56// NewStrategy is the default logic that applies when creating and updating ValidatingAdmissionPolicyBinding objects.
57func NewStrategy(authorizer authorizer.UnconditionalAuthorizer, policyGetter PolicyGetter, resourceResolver resolver.ResourceResolver) *validatingAdmissionPolicyBindingStrategy {
58 return &validatingAdmissionPolicyBindingStrategy{

pkg/proxy/conntrack/fake.go1

51:46unused-parameterparameter tableType is unused

pkg/proxy/conntrack/fake.go:51:46

50
51func (f *fakeHandler) ConntrackDeleteFilters(tableType netlink.ConntrackTableType, family netlink.InetFamily, netlinkFilters ...netlink.CustomConntrackFilter) (uint, error) {
52 f.mu.Lock()

pkg/proxy/healthcheck/healthcheck_test.go1

76:7unused-receiverreceiver fa is unused

pkg/proxy/healthcheck/healthcheck_test.go:76:7

75
76func (fa fakeAddr) Network() string {
77 return "tcp"

pkg/proxy/config/config.go1

224:60use-anyuse any instead of interface{}

pkg/proxy/config/config.go:224:60

223
224func (c *ServiceConfig) handleUpdateService(oldObj, newObj interface{}) {
225 oldService, ok := oldObj.(*v1.Service)

pkg/kubeapiserver/options/admission.go1

98:23use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/admission.go:98:23

97 (a.GenericAdmission.EnablePlugins != nil || a.GenericAdmission.DisablePlugins != nil) {
98 errs = append(errs, fmt.Errorf("admission-control and enable-admission-plugins/disable-admission-plugins flags are mutually exclusive"))
99 }

pkg/proxy/iptables/proxier_test.go1

709:3use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/iptables/proxier_test.go:709:3

708 if chain != nil {
709 sort.SliceStable(chain.Rules, func(i, j int) bool {
710 return orderByCommentServiceName(chain.Rules[i], chain.Rules[j])

pkg/proxy/endpointschangetracker_test.go1

382:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:382:2

381 }
382 multipleSubsetsIPsPorts1_s2 := func(eps *discovery.EndpointSlice) {
383 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/admission_test.go1

80:38add-constantstring literal "two" appears more than twice; define a constant

pkg/kubeapiserver/options/admission_test.go:80:38

79 name: "choose one",
80 all: []string{"one", "two"},
81 enabled: []string{"one"},

pkg/scheduler/backend/heap/heap_test.go1

254:44boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/scheduler/backend/heap/heap_test.go:254:44

253 h := New(testHeapObjectKeyFunc, compareInts)
254 if got := h.Has(mkHeapObj("foo", 0, 1)); got != false {
255 t.Errorf("Has(%q) = %v, want %v", "foo", got, false)

pkg/kubeapiserver/options/authentication.go1

670:40cognitive-complexityfunction has cognitive complexity 32; maximum is 7

pkg/kubeapiserver/options/authentication.go:670:40

669// The input context controls the lifecycle of background goroutines started to reload the authentication config file.
670func (o *BuiltInAuthenticationOptions) ApplyTo(
671 ctx context.Context,

pkg/registry/core/service/ipallocator/bitmap.go1

214:17confusing-namingname allocateNext differs from AllocateNext only by capitalization

pkg/registry/core/service/ipallocator/bitmap.go:214:17

213
214func (r *Range) allocateNext(dryRun bool) (net.IP, error) {
215 label := r.CIDR()

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go1

246:163confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go:246:163

245// need to check all the pods in the cluster.
246func (pl *InterPodAffinity) getIncomingAffinityAntiAffinityCounts(ctx context.Context, podInfo fwk.PodInfo, allNodes []fwk.NodeInfo) (topologyToMatchedTermCount, topologyToMatchedTermCount) {
247 affinityCounts := make(topologyToMatchedTermCount)

pkg/proxy/util/localdetector.go1

97:6constructor-interface-returnNewDetectLocalByBridgeInterface returns interface LocalTrafficDetector although its concrete result is consistently *detectLocal; return the concrete type

pkg/proxy/util/localdetector.go:97:6

96// non-local.
97func NewDetectLocalByBridgeInterface(interfaceName string) LocalTrafficDetector {
98 return &detectLocal{

pkg/proxy/apis/config/v1alpha1/defaults.go1

39:6cyclomatic-complexityfunction complexity is 22; maximum is 10

pkg/proxy/apis/config/v1alpha1/defaults.go:39:6

38
39func SetDefaults_KubeProxyConfiguration(obj *kubeproxyconfigv1alpha1.KubeProxyConfiguration) {
40

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

106:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.PKIXPublicKey is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty. Signer implementations should extract the public key from the StubPKCS10Request field.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:106:5

105 MaxExpirationSeconds: ptr.To[int32](86400),
106 PKIXPublicKey: ed25519PubPKIX1,
107 ProofOfPossession: ed25519Proof1,

pkg/proxy/conntrack/cleanup_test.go1

327:22discarded-error-resulterror result returned by ct.ListEntries is discarded

pkg/proxy/conntrack/cleanup_test.go:327:22

326 CleanStaleEntries(ct, testIPFamily, svcPortMap, endpointsMap)
327 actualEntries, _ := ct.ListEntries(ipFamilyMap[testIPFamily])
328

pkg/kubeapiserver/authorizer/modes/modes.go1

24:2doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/modes/modes.go:24:2

23 ModeAlwaysAllow string = "AlwaysAllow"
24 // ModeAlwaysDeny is the mode to set no requests as authorized
25 ModeAlwaysDeny string = "AlwaysDeny"

pkg/scheduler/framework/plugins/dynamicresources/nodeallocatabledynamicresources.go1

158:6early-returninvert the condition and return early to reduce nesting

pkg/scheduler/framework/plugins/dynamicresources/nodeallocatabledynamicresources.go:158:6

157 }
158 if consumed, exists := result.ConsumedCapacity[capacityKey]; exists {
159 quantity = consumed.DeepCopy()

pkg/kubeapiserver/options/authentication_test.go1

1241:14error-stringserror string should not be capitalized or end with punctuation

pkg/kubeapiserver/options/authentication_test.go:1241:14

1240 if len(errs) > 0 && len(tt.expectErr) == 0 {
1241 t.Errorf("Got err: %v, Expected err nil", errs)
1242 }

pkg/kubeapiserver/authorizer/reload.go1

81:40exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/authorizer/reload.go:81:40

80
81func (r *reloadableAuthorizerResolver) Authorize(ctx context.Context, a authorizer.Attributes) (authorized authorizer.Decision, reason string, err error) {
82 return r.current.Load().authorizer.Authorize(ctx, a)

pkg/proxy/healthcheck/healthcheck_test.go1

1:1file-length-limitfile has 1015 lines; maximum is 500

pkg/proxy/healthcheck/healthcheck_test.go:1:1

1/*
2Copyright 2016 The Kubernetes Authors.

pkg/proxy/ipvs/ipset.go1

103:80flag-parameterboolean parameter isIPv6 controls function flow

pkg/proxy/ipvs/ipset.go:103:80

102// NewIPSet initialize a new IPSet struct
103func NewIPSet(handle utilipset.Interface, name string, setType utilipset.Type, isIPv6 bool, comment string) *IPSet {
104 hashFamily := utilipset.ProtocolFamilyIPV4

pkg/kubeapiserver/default_storage_factory_builder.go1

1:1formatfile is not formatted

pkg/kubeapiserver/default_storage_factory_builder.go:1:1

1/*
2Copyright 2016 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/default_storage_factory_builder.go`

pkg/kubeapiserver/options/authentication_test.go1

314:6function-lengthfunction has 17 statements and 107 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:314:6

313
314func TestToAuthenticationConfig(t *testing.T) {
315 testOptions := &BuiltInAuthenticationOptions{

pkg/registry/core/pod/storage/storage_test.go1

55:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/core/pod/storage/storage_test.go:55:6

54
55func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *etcd3testing.EtcdTestServer) {
56 etcdStorage, server := registrytest.NewEtcdStorage(t, "")

pkg/kubeapiserver/options/authorization_test.go1

39:3import-shadowingidentifier modes shadows an imported package

pkg/kubeapiserver/options/authorization_test.go:39:3

38 name string
39 modes []string
40 policyFile string

pkg/registry/core/service/storage/transaction_test.go1

105:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:105:6

104 commit: func() {
105 temp = temp + 1
106 },

pkg/registry/batch/job/strategy.go1

236:3inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/registry/batch/job/strategy.go:236:3

235 if _, found := obj.Spec.Selector.MatchLabels[batch.ControllerUidLabel]; !found {
236 obj.Spec.Selector.MatchLabels[batch.ControllerUidLabel] = string(obj.ObjectMeta.UID)
237 }

pkg/scheduler/framework/parallelize/parallelism_test.go1

53:9inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/scheduler/framework/parallelize/parallelism_test.go:53:9

52 for _, test := range tests {
53 t.Run(fmt.Sprintf("%d", test.input), func(t *testing.T) {
54 if chunkSizeFor(test.input, DefaultParallelism) != test.wantOutput {

pkg/kubeapiserver/options/authentication_test.go1

201:15insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:201:15

200 Issuers: []string{"http://foo.bar.com"},
201 JWKSURI: "http://baz.com",
202 },

pkg/scheduler/backend/queue/scheduling_queue.go1

96:22interface-method-limitinterface has 32 methods, exceeding the configured design limit of 10

pkg/scheduler/backend/queue/scheduling_queue.go:96:22

95// makes it easy to use those data structures as a SchedulingQueue.
96type SchedulingQueue interface {
97 fwk.PodNominator

pkg/scheduler/framework/preemption/executor_test.go1

775:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/preemption/executor_test.go:775:8

774 } else {
775 if !cmp.Equal(status, tt.expectedStatus) {
776 t.Errorf("expect status %v, but got %v", tt.expectedStatus, status)

pkg/proxy/winkernel/hns.go1

545:16max-parametersfunction has 9 parameters; maximum is 8

pkg/proxy/winkernel/hns.go:545:16

544
545func (hns hns) updateLoadBalancer(hnsID string,
546 sourceVip,

pkg/scheduler/apis/config/types.go1

213:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types.go:213:6

212// It is up to the plugin to process these Args.
213type PluginConfig struct {
214 // Name defines the name of plugin being configured

pkg/proxy/apis/config/v1alpha1/conversion.go1

33:2modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:33:2

32 out.WindowsRunAsService = in.Windows.RunAsService
33 out.Conntrack = v1alpha1.KubeProxyConntrackConfiguration(in.Linux.Conntrack)
34 out.OOMScoreAdj = in.Linux.OOMScoreAdj

pkg/registry/rbac/validation/rule_test.go1

52:45modifies-value-receiverassignment modifies value receiver b

pkg/registry/rbac/validation/rule_test.go:52:45

51func (b byHash) Less(i, j int) bool { return hashOf(b[i]) < hashOf(b[j]) }
52func (b byHash) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
53

pkg/kubeapiserver/options/authorization_test.go1

37:17nested-structsmove nested anonymous struct types to named declarations

pkg/kubeapiserver/options/authorization_test.go:37:17

36
37 testCases := []struct {
38 name string

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

303:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:303:4

302 if err != nil {
303 return false, nil
304 }

pkg/proxy/nftables/proxier.go1

221:3nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/proxy/nftables/proxier.go:221:3

220 logger.Info("System initialized and --init-only specified")
221 return nil, nil
222 }

pkg/proxy/winkernel/proxier.go1

358:4no-else-after-returnremove else and unindent its body after the return

pkg/proxy/winkernel/proxier.go:358:4

357 return fmt.Sprintf("%v-%02x-%02x-%02x-%02x", macPrefix, a, b, c, d)
358 } else if ip6 := ip.To16(); ip6 != nil {
359 a, b, c, d := ip6[15], ip6[14], ip6[13], ip6[12]

pkg/scheduler/backend/queue/scheduling_queue_test.go1

108:6no-initreplace init with explicit initialization

pkg/scheduler/backend/queue/scheduling_queue_test.go:108:6

107
108func init() {
109 metrics.Register()

pkg/proxy/ipvs/proxier.go1

719:4no-naked-returnreturn values must be explicit

pkg/proxy/ipvs/proxier.go:719:4

718 if err := ensureIPSet(set); err != nil {
719 return
720 }

pkg/kubeapiserver/options/options.go1

27:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/options/options.go:27:5

26// DefaultServiceNodePortRange is the default port range for NodePort services.
27var DefaultServiceNodePortRange = utilnet.PortRange{Base: 30000, Size: 2768}
28

pkg/kubeapiserver/options/authentication.go1

655:6optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:655:6

654
655 if len(o.WebHook.ConfigFile) > 0 && o.WebHook.CacheTTL > 0 {
656 if o.TokenSuccessCacheTTL > 0 && o.WebHook.CacheTTL < o.TokenSuccessCacheTTL {

pkg/registry/rbac/role/strategy.go1

65:2overwritten-before-usethis value of newRole is overwritten before use

pkg/registry/rbac/role/strategy.go:65:2

64func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
65 newRole := obj.(*rbac.Role)
66 oldRole := old.(*rbac.Role)

pkg/kubeapiserver/options/admission.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/options/admission.go:17:9

16
17package options
18

pkg/scheduler/framework/plugins/interpodaffinity/plugin.go1

223:105possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/plugins/interpodaffinity/plugin.go:223:105

222
223 originalPodAntiTerms, err := fwk.GetAffinityTerms(originalPod, fwk.GetPodAntiAffinityTerms(originalPod.Spec.Affinity))
224 if err != nil {

pkg/proxy/iptables/proxier_test.go1

671:12range-value-addresstaking the address of range value t can be misleading

pkg/proxy/iptables/proxier_test.go:671:12

670 for t := range dump.Tables {
671 table := &dump.Tables[t]
672 sort.Slice(table.Chains, func(i, j int) bool {

pkg/registry/rbac/clusterrole/policybased/storage.go1

93:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/clusterrole/policybased/storage.go:93:7

92
93func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
94 if rbacregistry.EscalationAllowed(ctx) || rbacregistry.RoleEscalationAuthorized(ctx, s.authorizer) {

pkg/registry/certificates/clustertrustbundle/strategy.go1

67:57redefines-builtin-ididentifier new shadows a predeclared identifier

pkg/registry/certificates/clustertrustbundle/strategy.go:67:57

66
67func (s strategy) PrepareForUpdate(ctx context.Context, new, old runtime.Object) {}
68

pkg/proxy/apis/config/validation/validation_test.go1

440:10redundant-conversionconversion from config.ProxyMode to the identical type is redundant

pkg/proxy/apis/config/validation/validation_test.go:440:10

439 "blank mode should default": {
440 mode: kubeproxyconfig.ProxyMode(""),
441 },

pkg/proxy/healthcheck/healthcheck_test.go1

31:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/healthcheck/healthcheck_test.go:31:2

30
31 v1 "k8s.io/api/core/v1"
32 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

pkg/proxy/apis/config/v1alpha1/conversion.go1

68:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/apis/config/v1alpha1/conversion.go:68:2

67 out.Linux.OOMScoreAdj = in.OOMScoreAdj
68 switch kubeproxyconfig.ProxyMode(in.Mode) {
69 case kubeproxyconfig.ProxyModeNFTables:

pkg/proxy/ipvs/util/testing/fake.go1

144:2slice-preallocationpreallocate res with capacity len(range source) before appending once per iteration

pkg/proxy/ipvs/util/testing/fake.go:144:2

143func (f *FakeIPVS) GetVirtualServers() ([]*utilipvs.VirtualServer, error) {
144 res := make([]*utilipvs.VirtualServer, 0)
145 for _, svc := range f.Services {

pkg/proxy/config/config_test.go1

860:1task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/config/config_test.go:860:1

859
860// TODO: Add a unittest for interrupts getting processed in a timely manner.
861

pkg/kubeapiserver/options/authentication_test.go1

422:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/authentication_test.go:422:6

421
422func TestBuiltInAuthenticationOptionsAddFlags(t *testing.T) {
423 var args = []string{

pkg/proxy/apis/config/types.go1

252:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/apis/config/types.go:252:1

251
252const (
253 ProxyModeIPTables ProxyMode = "iptables"

pkg/proxy/winkernel/hns.go1

660:11unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/hns.go:660:11

659 if r := recover(); r != nil {
660 err = r.(error)
661 hash = [20]byte{}

pkg/registry/core/rest/storage_core.go1

111:68unexported-returnexported function returns an unexported type

pkg/registry/core/rest/storage_core.go:111:68

110
111func New(c Config, authorizer authorizer.UnconditionalAuthorizer) (*legacyProvider, error) {
112 rangeRegistries, serviceClusterIPAllocator, serviceIPAllocators, serviceNodePortAllocator, err := c.newServiceIPAllocators()

pkg/proxy/conntrack/fake.go1

51:84unused-parameterparameter family is unused

pkg/proxy/conntrack/fake.go:51:84

50
51func (f *fakeHandler) ConntrackDeleteFilters(tableType netlink.ConntrackTableType, family netlink.InetFamily, netlinkFilters ...netlink.CustomConntrackFilter) (uint, error) {
52 f.mu.Lock()

pkg/proxy/healthcheck/healthcheck_test.go1

79:7unused-receiverreceiver fa is unused

pkg/proxy/healthcheck/healthcheck_test.go:79:7

78}
79func (fa fakeAddr) String() string {
80 return "<test>"

pkg/proxy/config/config.go1

241:49use-anyuse any instead of interface{}

pkg/proxy/config/config.go:241:49

240
241func (c *ServiceConfig) handleDeleteService(obj interface{}) {
242 service, ok := obj.(*v1.Service)

pkg/kubeapiserver/options/authentication.go1

267:35use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication.go:267:35

266 if issuer == "" {
267 allErrors = append(allErrors, fmt.Errorf("service-account-issuer should not be an empty string"))
268 continue

pkg/proxy/iptables/proxier_test.go1

718:3use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/iptables/proxier_test.go:718:3

717 if chain != nil {
718 sort.SliceStable(chain.Rules, func(i, j int) bool {
719 return orderByCommentServiceName(chain.Rules[i], chain.Rules[j])

pkg/proxy/endpointschangetracker_test.go1

426:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:426:2

425 }
426 complexBefore2_s1 := func(eps *discovery.EndpointSlice) {
427 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/authentication_test.go1

106:20add-constantstring literal "sub" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:106:20

105 testOIDC: &OIDCAuthenticationOptions{
106 UsernameClaim: "sub",
107 SigningAlgs: []string{"RS256"},

pkg/scheduler/backend/heap/heap_test.go1

262:44boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/scheduler/backend/heap/heap_test.go:262:44

261 h.AddOrUpdate(mkHeapObj("bar", 1, 1))
262 if got := h.Has(mkHeapObj("foo", 0, 1)); got != false {
263 t.Errorf("Has(%q) = %v, want %v", "foo", got, false)

pkg/kubeapiserver/options/authentication_test.go1

58:6cognitive-complexityfunction has cognitive complexity 11; maximum is 7

pkg/kubeapiserver/options/authentication_test.go:58:6

57
58func TestAuthenticationValidate(t *testing.T) {
59 testCases := []struct {

pkg/registry/core/service/ipallocator/bitmap.go1

250:17confusing-namingname release differs from Release only by capitalization

pkg/registry/core/service/ipallocator/bitmap.go:250:17

249
250func (r *Range) release(ip net.IP, dryRun bool) error {
251 ok, offset := r.contains(ip)

pkg/scheduler/framework/plugins/noderesources/resource_allocation.go1

319:11confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/noderesources/resource_allocation.go:319:11

318 draPreScoreState *draPreScoreState,
319) (int64, int64) {
320 logger := klog.FromContext(ctx)

pkg/proxy/util/localdetector.go1

109:6constructor-interface-returnNewDetectLocalByInterfaceNamePrefix returns interface LocalTrafficDetector although its concrete result is consistently *detectLocal; return the concrete type

pkg/proxy/util/localdetector.go:109:6

108// traffic from other interfaces to be non-local.
109func NewDetectLocalByInterfaceNamePrefix(interfacePrefix string) LocalTrafficDetector {
110 return &detectLocal{

pkg/proxy/conntrack/cleanup.go1

45:6cyclomatic-complexityfunction complexity is 18; maximum is 10

pkg/proxy/conntrack/cleanup.go:45:6

44// based on the current Services and Endpoints.
45func CleanStaleEntries(ct Interface, ipFamily v1.IPFamily,
46 svcPortMap proxy.ServicePortMap, endpointsMap proxy.EndpointsMap) {

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

107:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.ProofOfPossession is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:107:5

106 PKIXPublicKey: ed25519PubPKIX1,
107 ProofOfPossession: ed25519Proof1,
108 UnverifiedUserAnnotations: map[string]string{"test/foo": "bar"},

pkg/proxy/conntrack/cleanup_test.go1

434:22discarded-error-resulterror result returned by ct.ListEntries is discarded

pkg/proxy/conntrack/cleanup_test.go:434:22

433 CleanStaleEntries(ct, testIPFamily, svcPortMap, endpointsMap)
434 actualEntries, _ := ct.ListEntries(ipFamilyMap[testIPFamily])
435 if len(actualEntries) != expectedEntries {

pkg/kubeapiserver/authorizer/modes/modes.go1

26:2doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/modes/modes.go:26:2

25 ModeAlwaysDeny string = "AlwaysDeny"
26 // ModeABAC is the mode to use Attribute Based Access Control to authorize
27 ModeABAC string = "ABAC"

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go1

397:3early-returninvert the condition and return early to reduce nesting

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go:397:3

396 for _, term := range state.podInfo.GetRequiredAffinityTerms() {
397 if topologyValue, ok := nodeInfo.Node().Labels[term.TopologyKey]; ok {
398 tp := topologyPair{key: term.TopologyKey, value: topologyValue}

pkg/proxy/apis/config/v1alpha1/defaults_test.go1

136:14error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/apis/config/v1alpha1/defaults_test.go:136:14

135 if diff := cmp.Diff(tc.expected, tc.original); diff != "" {
136 t.Errorf("Got unexpected defaults (-want, +got):\n%s", diff)
137 }

pkg/kubeapiserver/authorizer/reload.go1

95:40exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/authorizer/reload.go:95:40

94
95func (r *reloadableAuthorizerResolver) RulesFor(ctx context.Context, user user.Info, namespace string) ([]authorizer.ResourceRuleInfo, []authorizer.NonResourceRuleInfo, bool, error) {
96 return r.current.Load().ruleResolver.RulesFor(ctx, user, namespace)

pkg/proxy/iptables/proxier.go1

1:1file-length-limitfile has 1475 lines; maximum is 500

pkg/proxy/iptables/proxier.go:1:1

1//go:build linux
2

pkg/proxy/ipvs/ipset/ipset.go1

300:45flag-parameterboolean parameter ignoreExistErr controls function flow

pkg/proxy/ipvs/ipset/ipset.go:300:45

299// otherwise raised when the same set (setname and create parameters are identical) already exists.
300func (runner *runner) createSet(set *IPSet, ignoreExistErr bool) error {
301 args := []string{"create", set.Name, string(set.SetType)}

pkg/kubeapiserver/options/admission.go1

1:1formatfile is not formatted

pkg/kubeapiserver/options/admission.go:1:1

1/*
2Copyright 2018 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/options/admission.go`

pkg/kubeapiserver/options/authentication_test.go1

422:6function-lengthfunction has 9 statements and 90 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:422:6

421
422func TestBuiltInAuthenticationOptionsAddFlags(t *testing.T) {
423 var args = []string{

pkg/registry/core/rest/storage_core.go1

332:18function-result-limitfunction returns 5 values; maximum is 3

pkg/registry/core/rest/storage_core.go:332:18

331
332func (c *Config) newServiceIPAllocators() (registries rangeRegistries, primaryClusterIPAllocator ipallocator.Interface, clusterIPAllocators map[api.IPFamily]ipallocator.Interface, nodePortAllocator *portallocator.PortAllocator, err error) {
333 clusterIPAllocators = map[api.IPFamily]ipallocator.Interface{}

pkg/proxy/config/config_test.go1

291:6import-shadowingidentifier slices shadows an imported package

pkg/proxy/config/config_test.go:291:6

290 // if the consumer falls behind. Unittests will hard timeout in 5m.
291 var slices []*discoveryv1.EndpointSlice
292 for {

pkg/registry/core/service/storage/transaction_test.go1

108:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:108:6

107 revert: func() {
108 temp = temp - 1
109 },

pkg/registry/core/pod/strategy.go1

254:4inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/registry/core/pod/strategy.go:254:4

253 oldGeneration = oldGenerations[0]
254 oldConditionGenerations[newCondition.Type] = oldGenerations[1:]
255 }

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go1

4232:27inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go:4232:27

4231 inUseUIDs.Insert(obj.GetUID())
4232 obj.SetResourceVersion(fmt.Sprintf("%d", resourceVersionCounter))
4233 resourceVersionCounter++

pkg/kubeapiserver/options/authentication_test.go1

216:24insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:216:24

215 KeyFiles: []string{"cert", "key"},
216 Issuers: []string{"http://foo.bar.com"},
217 JWKSURI: "https://baz.com",

pkg/scheduler/framework/interface.go1

191:16interface-method-limitinterface has 63 methods, exceeding the configured design limit of 10

pkg/scheduler/framework/interface.go:191:16

190// Configured plugins are called at specified points in a scheduling context.
191type Framework interface {
192 fwk.Handle

pkg/scheduler/framework/preemption/executor_test.go1

804:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/preemption/executor_test.go:804:8

803 if asyncPreemptionEnabled {
804 if diff := cmp.Diff(tt.expectedActivatedPods, fakeActivator.activatedPods); tt.expectedActivatedPods != nil && diff != "" {
805 lastErrMsg = fmt.Sprintf("Unexpected activated pods (-want,+got):\n%s", diff)

pkg/proxy/winkernel/proxier.go1

734:6max-parametersfunction has 10 parameters; maximum is 8

pkg/proxy/winkernel/proxier.go:734:6

733// allow internal testing of proxier
734func newProxierInternal(
735 ipFamily v1.IPFamily,

pkg/scheduler/apis/config/types.go1

271:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types.go:271:6

270// it is assumed that the extender chose not to provide that extension.
271type Extender struct {
272 // URLPrefix at which the extender is available

pkg/proxy/apis/config/v1alpha1/conversion.go1

34:2modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:34:2

33 out.Conntrack = v1alpha1.KubeProxyConntrackConfiguration(in.Linux.Conntrack)
34 out.OOMScoreAdj = in.Linux.OOMScoreAdj
35 switch in.Mode {

pkg/scheduler/framework/plugins/dynamicresources/claims.go1

133:2modifies-value-receiverassignment modifies value receiver cs

pkg/scheduler/framework/plugins/dynamicresources/claims.go:133:2

132func (cs claimStore) set(i int, c *resourceapi.ResourceClaim) {
133 cs.claims[i] = c
134}

pkg/proxy/apis/config/v1alpha1/defaults_test.go1

37:17nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/v1alpha1/defaults_test.go:37:17

36 ctMin := int32(131072)
37 testCases := []struct {
38 name string

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

341:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:341:4

340 if err != nil {
341 return false, nil
342 }

pkg/registry/core/pod/storage/eviction_test.go1

1009:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/core/pod/storage/eviction_test.go:1009:2

1008func (ms *mockStore) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
1009 return nil, nil
1010}

pkg/registry/admissionregistration/rest/storage_apiserver.go1

52:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/admissionregistration/rest/storage_apiserver.go:52:4

51 return genericapiserver.APIGroupInfo{}, err
52 } else if len(storageMap) > 0 {
53 apiGroupInfo.VersionedResourcesStorageMap[admissionregistrationv1.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/plugins/defaultbinder/default_binder_test.go1

42:6no-initreplace init with explicit initialization

pkg/scheduler/framework/plugins/defaultbinder/default_binder_test.go:42:6

41
42func init() {
43 metrics.Register()

pkg/proxy/ipvs/proxier.go1

1197:3no-naked-returnreturn values must be explicit

pkg/proxy/ipvs/proxier.go:1197:3

1196 metrics.IPTablesRestoreFailuresTotal.WithLabelValues(string(proxier.ipFamily)).Inc()
1197 return
1198 }

pkg/kubeapiserver/options/options.go1

30:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/options/options.go:30:5

29// DefaultServiceIPCIDR is a CIDR notation of IP range from which to allocate service cluster IPs
30var DefaultServiceIPCIDR = net.IPNet{IP: netutils.ParseIPSloppy("10.0.0.0"), Mask: net.CIDRMask(24, 32)}
31

pkg/kubeapiserver/options/authentication.go1

706:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:706:5

705 authInfo.APIAudiences = o.APIAudiences
706 if o.ServiceAccounts != nil && len(o.ServiceAccounts.Issuers) != 0 && len(o.APIAudiences) == 0 {
707 authInfo.APIAudiences = authenticator.Audiences(o.ServiceAccounts.Issuers)

pkg/registry/rbac/role/strategy.go1

66:2overwritten-before-usethis value of oldRole is overwritten before use

pkg/registry/rbac/role/strategy.go:66:2

65 newRole := obj.(*rbac.Role)
66 oldRole := old.(*rbac.Role)
67

pkg/kubeapiserver/options/authentication.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/options/authentication.go:17:9

16
17package options
18

pkg/scheduler/framework/plugins/nodeaffinity/node_affinity.go1

161:36possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/plugins/nodeaffinity/node_affinity.go:161:36

160
161 if noNodeAffinity || len(affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms) == 0 {
162 return nil, nil

pkg/proxy/ipvs/proxier.go1

864:13range-value-addresstaking the address of range value externalIP can be misleading

pkg/proxy/ipvs/proxier.go:864:13

863 // ipset call
864 entry := &utilipset.Entry{
865 IP: externalIP.String(),

pkg/registry/rbac/clusterrole/policybased/storage.go1

130:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/clusterrole/policybased/storage.go:130:7

129
130func (s *Storage) GetSingularName() string {
131 snp, ok := s.StandardStorage.(rest.SingularNameProvider)

pkg/registry/certificates/clustertrustbundle/strategy.go1

69:55redefines-builtin-ididentifier new shadows a predeclared identifier

pkg/registry/certificates/clustertrustbundle/strategy.go:69:55

68
69func (s strategy) ValidateUpdate(ctx context.Context, new, old runtime.Object) field.ErrorList {
70 newBundle := new.(*certificates.ClusterTrustBundle)

pkg/proxy/apis/config/validation/validation_test.go1

482:18redundant-conversionconversion from config.ProxyMode to the identical type is redundant

pkg/proxy/apis/config/validation/validation_test.go:482:18

481 "invalid mode non-existent": {
482 mode: kubeproxyconfig.ProxyMode("non-existing"),
483 expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ProxyMode"), "non-existing", "must be iptables, ipvs, nftables or blank (blank means the best-available proxy [currently iptables])")},

pkg/proxy/healthcheck/proxy_health.go1

27:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/healthcheck/proxy_health.go:27:2

26
27 v1 "k8s.io/api/core/v1"
28 "k8s.io/klog/v2"

pkg/proxy/apis/config/v1alpha1/conversion.go1

75:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/apis/config/v1alpha1/conversion.go:75:2

74
75 switch kubeproxyconfig.ProxyMode(in.Mode) {
76 case kubeproxyconfig.ProxyModeIPVS:

pkg/proxy/servicechangetracker_test.go1

87:6slice-preallocationpreallocate ips with capacity len(range source) before appending once per iteration

pkg/proxy/servicechangetracker_test.go:87:6

86func makeIPs(ipStr ...string) []net.IP {
87 var ips []net.IP
88 for _, s := range ipStr {

pkg/proxy/endpointschangetracker.go1

105:3task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/endpointschangetracker.go:105:3

104 // we want to measure. So we simply ignore it in this cases.
105 // TODO(wojtek-t, robscott): Address the problem for EndpointSlice deletion
106 // when other EndpointSlice for that service still exist.

pkg/kubeapiserver/options/authentication_test.go1

513:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/authentication_test.go:513:6

512
513func TestWithTokenGetterFunction(t *testing.T) {
514 fakeClientset := fake.NewSimpleClientset()

pkg/proxy/config/config.go1

167:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/config/config.go:167:1

166// ServiceConfig tracks a set of service configurations.
167type ServiceConfig struct {
168 listerSynced cache.InformerSynced

pkg/proxy/winkernel/proxier_test.go1

490:22unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/proxier_test.go:490:22

489
490 hcn := (proxier.hcn).(*fakehcn.HcnMock)
491 // Populating the endpoint to the cache, since it's a local endpoint and local endpoints are managed by CNI and not KubeProxy

pkg/registry/flowcontrol/ensurer/flowschema_test.go1

396:49unexported-returnexported function returns an unexported type

pkg/registry/flowcontrol/ensurer/flowschema_test.go:396:49

395
396func (b *fsBuilder) WithGeneration(value int64) *fsBuilder {
397 b.object.SetGeneration(value)

pkg/proxy/conntrack/sysctls_test.go1

92:35unused-parameterparameter ctx is unused

pkg/proxy/conntrack/sysctls_test.go:92:35

91// SetMax value is calculated based on the number of CPUs by getConntrackMax()
92func (fc *fakeConntracker) SetMax(ctx context.Context, max int) error {
93 fc.called = append(fc.called, "SetMax")

pkg/proxy/healthcheck/healthcheck_test.go1

82:7unused-receiverreceiver fake is unused

pkg/proxy/healthcheck/healthcheck_test.go:82:7

81}
82func (fake *fakeNetListener) Accept() (net.Conn, error) {
83 // Not implemented

pkg/proxy/config/config.go1

290:25use-anyuse any instead of interface{}

pkg/proxy/config/config.go:290:25

289 cache.ResourceEventHandlerFuncs{
290 AddFunc: func(obj interface{}) { result.handleChangeNode(obj) },
291 UpdateFunc: func(_, newObj interface{}) { result.handleChangeNode(newObj) },

pkg/kubeapiserver/options/authentication.go1

316:7use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication.go:316:7

315 allErrors = append(allErrors,
316 fmt.Errorf("--requestheader-client-ca-file and --client-ca-file contain overlapping certificates; --requestheader-allowed-names must be specified to ensure regular client certificates cannot set authenticating proxy headers for arbitrary users"))
317 }

pkg/proxy/iptables/proxier_test.go1

724:3use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/iptables/proxier_test.go:724:3

723 if chain != nil {
724 sort.SliceStable(chain.Rules, func(i, j int) bool {
725 if chain.Rules[i].Comment != nil && strings.Contains(chain.Rules[i].Comment.Value, "must be the last rule") {

pkg/proxy/endpointschangetracker_test.go1

440:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:440:2

439 }
440 complexBefore2_s2 := func(eps *discovery.EndpointSlice) {
441 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/authentication_test.go1

107:29add-constantstring literal "RS256" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:107:29

106 UsernameClaim: "sub",
107 SigningAlgs: []string{"RS256"},
108 IssuerURL: "https://testIssuerURL",

pkg/scheduler/backend/heap/heap_test.go1

270:44boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/scheduler/backend/heap/heap_test.go:270:44

269 h.AddOrUpdate(mkHeapObj("foo", 10, 1))
270 if got := h.Has(mkHeapObj("foo", 0, 1)); got != true {
271 t.Errorf("Has(%q) = %v, want %v", "foo", got, true)

pkg/kubeapiserver/options/authentication_test.go1

542:6cognitive-complexityfunction has cognitive complexity 15; maximum is 7

pkg/kubeapiserver/options/authentication_test.go:542:6

541
542func TestToAuthenticationConfig_Anonymous(t *testing.T) {
543 testCases := []struct {

pkg/registry/core/service/ipallocator/cidrallocator.go1

104:6confusing-namingname newMetaAllocator differs from NewMetaAllocator only by capitalization

pkg/registry/core/service/ipallocator/cidrallocator.go:104:6

103// newMetaAllocator is used to build the allocator for testing
104func newMetaAllocator(client networkingv1client.NetworkingV1Interface,
105 serviceCIDRInformer networkingv1informers.ServiceCIDRInformer,

pkg/scheduler/framework/plugins/noderesources/resource_allocation.go1

355:11confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/noderesources/resource_allocation.go:355:11

354func (r *resourceAllocationScorer) calculateDRAResourceTotals(ctx context.Context, node *v1.Node, deviceClass *resourceapi.DeviceClass, allocatedState *structured.AllocatedState, resourceSlices []*resourceapi.ResourceSlice,
355) (int64, int64, error) {
356 var totalCapacity, totalAllocated int64

pkg/registry/admissionregistration/resolver/resolver.go1

64:6constructor-interface-returnNewDiscoveryResourceResolver returns interface ResourceResolver although its concrete result is consistently *discoveryResourceResolver; return the concrete type

pkg/registry/admissionregistration/resolver/resolver.go:64:6

63
64func NewDiscoveryResourceResolver(client discovery.DiscoveryInterface) (ResourceResolver, error) {
65 return &discoveryResourceResolver{client: client}, nil

pkg/proxy/conntrack/cleanup_test.go1

89:6cyclomatic-complexityfunction complexity is 29; maximum is 10

pkg/proxy/conntrack/cleanup_test.go:89:6

88
89func TestCleanStaleEntries(t *testing.T) {
90 // We need to construct proxy.ServicePortMap and proxy.EndpointsMap to pass to

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

126:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.PKIXPublicKey is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty. Signer implementations should extract the public key from the StubPKCS10Request field.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:126:5

125 MaxExpirationSeconds: ptr.To[int32](86400),
126 PKIXPublicKey: ed25519PubPKIX2,
127 ProofOfPossession: ed25519Proof2,

pkg/proxy/conntrack/cleanup_test.go1

551:22discarded-error-resulterror result returned by ct.ListEntries is discarded

pkg/proxy/conntrack/cleanup_test.go:551:22

550 CleanStaleEntries(ct, testIPFamily, svcPortMap, endpointsMap)
551 actualEntries, _ := ct.ListEntries(ipFamilyMap[testIPFamily])
552

pkg/kubeapiserver/authorizer/modes/modes.go1

28:2doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/modes/modes.go:28:2

27 ModeABAC string = "ABAC"
28 // ModeWebhook is the mode to make an external webhook call to authorize
29 ModeWebhook string = "Webhook"

pkg/scheduler/framework/runtime/framework.go1

492:4early-returninvert the condition and return early to reduce nesting

pkg/scheduler/framework/runtime/framework.go:492:4

491 if gs, ok := f.pluginsMap[names.GangScheduling]; ok {
492 if p, ok := gs.(framework.PlacementFeasiblePlugin); ok {
493 f.placementFeasiblePlugins = append(f.placementFeasiblePlugins, p)

pkg/proxy/config/config_test.go1

121:13error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/config/config_test.go:121:13

120 case <-time.After(wait.ForeverTestTimeout):
121 t.Errorf("Timed out. Expected %#v, Got %#v", expectedServices, services)
122 return

pkg/kubeapiserver/default_storage_factory_builder.go1

56:6exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/default_storage_factory_builder.go:56:6

55// should be disabled.
56func DefaultWatchCacheSizes() map[schema.GroupResource]int {
57 return map[schema.GroupResource]int{

pkg/proxy/iptables/proxier_test.go1

1:1file-length-limitfile has 6691 lines; maximum is 500

pkg/proxy/iptables/proxier_test.go:1:1

1//go:build linux
2

pkg/proxy/ipvs/ipset/ipset.go1

324:58flag-parameterboolean parameter ignoreExistErr controls function flow

pkg/proxy/ipvs/ipset/ipset.go:324:58

323// the same set (setname and create parameters are identical) already exists.
324func (runner *runner) AddEntry(entry string, set *IPSet, ignoreExistErr bool) error {
325 args := []string{"add", set.Name, entry}

pkg/kubeapiserver/options/admission_test.go1

1:1formatfile is not formatted

pkg/kubeapiserver/options/admission_test.go:1:1

1/*
2Copyright 2018 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/options/admission_test.go`

pkg/kubeapiserver/options/authentication_test.go1

542:6function-lengthfunction has 19 statements and 252 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:542:6

541
542func TestToAuthenticationConfig_Anonymous(t *testing.T) {
543 testCases := []struct {

pkg/registry/core/service/allocator/storage/storage_test.go1

32:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/core/service/allocator/storage/storage_test.go:32:6

31
32func newStorage(t *testing.T) (*Etcd, *etcd3testing.EtcdTestServer, allocator.Interface, *storagebackend.Config) {
33 etcdStorage, server := registrytest.NewEtcdStorage(t, "")

pkg/proxy/healthcheck/proxy_health.go1

71:2import-shadowingidentifier clock shadows an imported package

pkg/proxy/healthcheck/proxy_health.go:71:2

70 httpFactory httpServerFactory
71 clock clock.Clock
72

pkg/registry/core/service/storage/transaction_test.go1

131:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:131:6

130 commit: func() {
131 temp = temp + 1
132 },

pkg/registry/core/service/ipallocator/controller/repair.go1

169:5inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/registry/core/service/ipallocator/controller/repair.go:169:5

168
169 snapshotByFamily[family] = snapshot
170 }

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go1

4235:41inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go:4235:41

4234 if obj.GetName() == "" {
4235 obj.SetName(obj.GetGenerateName() + fmt.Sprintf("%d", nameCounter))
4236 nameCounter++

pkg/kubeapiserver/options/authentication_test.go1

346:22insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:346:22

345 Lookup: true,
346 Issuers: []string{"http://foo.bar.com"},
347 },

pkg/scheduler/framework/types.go1

557:23interface-method-limitinterface has 25 methods, exceeding the configured design limit of 10

pkg/scheduler/framework/types.go:557:23

556// It can be a single Pod (QueuedPodInfo) or a group of Pods (QueuedPodGroupInfo).
557type QueuedEntityInfo interface {
558 fwk.QueuedEntityInfo

pkg/scheduler/framework/preemption/executor_test.go1

808:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/preemption/executor_test.go:808:8

807 }
808 if tt.expectedActivatedPods == nil && len(fakeActivator.activatedPods) != 0 {
809 lastErrMsg = fmt.Sprintf("expected no activated pods, got %v", fakeActivator.activatedPods)

pkg/proxy/winkernel/proxier.go1

1822:25max-parametersfunction has 10 parameters; maximum is 8

pkg/proxy/winkernel/proxier.go:1822:25

1821// If it is needed, the function will delete the existing loadbalancer and return true, else false.
1822func (proxier *Proxier) deleteExistingLoadBalancer(hns HostNetworkService, winProxyOptimization bool, lbHnsID *string, vip string, protocol, intPort, extPort uint16, endpoints []endpointInfo, queriedLoadBalancers map[loadBalancerIdentifier]*loadBalancerInfo, lbType loadBalancerType) bool {
1823

pkg/scheduler/apis/config/types.go1

315:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types.go:315:6

314// managed by an extender.
315type ExtenderManagedResource struct {
316 // Name is the extended resource name.

pkg/proxy/apis/config/v1alpha1/conversion.go1

37:3modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:37:3

36 case kubeproxyconfig.ProxyModeNFTables:
37 out.NFTables.MasqueradeAll = in.Linux.MasqueradeAll
38 default:

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go1

95:3modifies-value-receiverassignment modifies value receiver m

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go:95:3

94 for pair, count := range toMerge {
95 m[pair] += count
96 }

pkg/proxy/apis/config/validation/validation_test.go1

68:26nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/validation/validation_test.go:68:26

67
68 testCases := map[string]struct {
69 mutateConfigFunc func(*kubeproxyconfig.KubeProxyConfiguration)

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

395:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:395:4

394 if err != nil {
395 return false, nil
396 }

pkg/registry/core/pod/storage/eviction_test.go1

1025:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/core/pod/storage/eviction_test.go:1025:2

1024func (ms *mockStore) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
1025 return nil, nil
1026}

pkg/registry/admissionregistration/rest/storage_apiserver.go1

58:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/admissionregistration/rest/storage_apiserver.go:58:4

57 return genericapiserver.APIGroupInfo{}, err
58 } else if len(storageMap) > 0 {
59 apiGroupInfo.VersionedResourcesStorageMap[admissionregistrationv1beta1.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go1

112:6no-initreplace init with explicit initialization

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go:112:6

111
112func init() {
113 metrics.Register()

pkg/proxy/ipvs/proxier.go1

1253:2no-naked-returnreturn values must be explicit

pkg/proxy/ipvs/proxier.go:1253:2

1252 }
1253 return
1254}

pkg/kubeapiserver/options/plugins.go1

73:5no-package-varpackage variables introduce mutable global state

pkg/kubeapiserver/options/plugins.go:73:5

72// AllOrderedPlugins is the list of all the plugins in order.
73var AllOrderedPlugins = []string{
74 admit.PluginName, // AlwaysAdmit

pkg/kubeapiserver/options/authentication.go1

832:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication.go:832:5

831func (o *BuiltInAuthenticationOptions) ApplyAuthorization(authorization *BuiltInAuthorizationOptions) {
832 if o == nil || authorization == nil || o.Anonymous == nil {
833 return

pkg/registry/rbac/rolebinding/strategy.go1

65:2overwritten-before-usethis value of newRoleBinding is overwritten before use

pkg/registry/rbac/rolebinding/strategy.go:65:2

64func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
65 newRoleBinding := obj.(*rbac.RoleBinding)
66 oldRoleBinding := old.(*rbac.RoleBinding)

pkg/kubeapiserver/options/authorization.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/options/authorization.go:17:9

16
17package options
18

pkg/scheduler/framework/plugins/nodeaffinity/node_affinity.go1

166:20possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/plugins/nodeaffinity/node_affinity.go:166:20

165 // Check if there is affinity to a specific node and return it.
166 terms := affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms
167 var nodeNames sets.Set[string]

pkg/proxy/ipvs/proxier.go1

887:12range-value-addresstaking the address of range value externalIP can be misleading

pkg/proxy/ipvs/proxier.go:887:12

886 // ipvs call
887 serv := &utilipvs.VirtualServer{
888 Address: externalIP,

pkg/registry/rbac/clusterrolebinding/policybased/storage.go1

69:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/clusterrolebinding/policybased/storage.go:69:7

68
69func (s *Storage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
70 if rbacregistry.EscalationAllowed(ctx) {

pkg/registry/certificates/podcertificaterequest/strategy.go1

93:58redefines-builtin-ididentifier new shadows a predeclared identifier

pkg/registry/certificates/podcertificaterequest/strategy.go:93:58

92
93func (s *Strategy) PrepareForUpdate(ctx context.Context, new, old runtime.Object) {
94 newReq := new.(*certificates.PodCertificateRequest)

pkg/proxy/apis/config/validation/validation_test.go1

510:10redundant-conversionconversion from config.ProxyMode to the identical type is redundant

pkg/proxy/apis/config/validation/validation_test.go:510:10

509 "blank mode should default": {
510 mode: kubeproxyconfig.ProxyMode(""),
511 },

pkg/proxy/healthcheck/service_health.go1

30:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/healthcheck/service_health.go:30:2

29
30 v1 "k8s.io/api/core/v1"
31 "k8s.io/apimachinery/pkg/types"

pkg/proxy/apis/config/validation/validation.go1

50:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/apis/config/validation/validation.go:50:2

49 allErrs = append(allErrs, validateKubeProxyIPTablesConfiguration(config.IPTables, newPath.Child("KubeProxyIPTablesConfiguration"))...)
50 switch config.Mode {
51 case kubeproxyconfig.ProxyModeIPVS:

pkg/proxy/util/nfacct/nfacct_linux.go1

163:2slice-preallocationpreallocate counters with capacity len(range source) before appending once per iteration

pkg/proxy/util/nfacct/nfacct_linux.go:163:2

162
163 counters := make([]*Counter, 0)
164 for _, msg := range msgs {

pkg/proxy/endpointschangetracker.go1

148:2task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/endpointschangetracker.go:148:2

147func getLastChangeTriggerTime(annotations map[string]string) time.Time {
148 // TODO(#81360): ignore case when Endpoint is deleted.
149 if _, ok := annotations[v1.EndpointsLastChangeTriggerTime]; !ok {

pkg/kubeapiserver/options/authentication_test.go1

542:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/authentication_test.go:542:6

541
542func TestToAuthenticationConfig_Anonymous(t *testing.T) {
543 testCases := []struct {

pkg/proxy/config/config_test.go1

224:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/config/config_test.go:224:1

223
224type EndpointSliceHandlerMock struct {
225 lock sync.Mutex

pkg/proxy/winkernel/proxier_test.go1

1409:22unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/proxier_test.go:1409:22

1408
1409 hcn := (proxier.hcn).(*fakehcn.HcnMock)
1410 proxier.rootHnsEndpointName = endpointGw

pkg/registry/flowcontrol/ensurer/flowschema_test.go1

401:60unexported-returnexported function returns an unexported type

pkg/registry/flowcontrol/ensurer/flowschema_test.go:401:60

400
401func (b *fsBuilder) WithAutoUpdateAnnotation(value string) *fsBuilder {
402 setAnnotation(b.object, value)

pkg/proxy/conntrack/sysctls_test.go1

92:56unused-parameterparameter max is unused

pkg/proxy/conntrack/sysctls_test.go:92:56

91// SetMax value is calculated based on the number of CPUs by getConntrackMax()
92func (fc *fakeConntracker) SetMax(ctx context.Context, max int) error {
93 fc.called = append(fc.called, "SetMax")

pkg/proxy/healthcheck/healthcheck_test.go1

92:7unused-receiverreceiver fake is unused

pkg/proxy/healthcheck/healthcheck_test.go:92:7

91
92func (fake *fakeNetListener) Addr() net.Addr {
93 // Not implemented

pkg/proxy/config/config.go1

291:31use-anyuse any instead of interface{}

pkg/proxy/config/config.go:291:31

290 AddFunc: func(obj interface{}) { result.handleChangeNode(obj) },
291 UpdateFunc: func(_, newObj interface{}) { result.handleChangeNode(newObj) },
292 DeleteFunc: result.handleDeleteNode,

pkg/kubeapiserver/options/authentication.go1

622:39use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication.go:622:39

621 case len(o.ServiceAccounts.KeyFiles) > 0 && o.ServiceAccounts.ExternalPublicKeysGetter != nil:
622 return kubeauthenticator.Config{}, fmt.Errorf("cannot set mutually exclusive flags `--service-account-key-file` and `--service-account-signing-endpoint` at the same time")
623 case len(o.ServiceAccounts.KeyFiles) > 0:

pkg/proxy/nftables/helpers_test.go1

78:2use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/proxy/nftables/helpers_test.go:78:2

77 // sort remaining lines
78 sort.SliceStable(lines, func(i, j int) bool {
79 li := lines[i]

pkg/proxy/endpointschangetracker_test.go1

451:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:451:2

450 }
451 complexBefore4_s1 := func(eps *discovery.EndpointSlice) {
452 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/authentication_test.go1

108:20add-constantstring literal "https://testIssuerURL" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:108:20

107 SigningAlgs: []string{"RS256"},
108 IssuerURL: "https://testIssuerURL",
109 ClientID: "testClientID",

pkg/scheduler/backend/heap/heap_test.go1

280:44boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/scheduler/backend/heap/heap_test.go:280:44

279 h.AddOrUpdate(mkHeapObj("baz", 11, 1))
280 if got := h.Has(mkHeapObj("foo", 0, 1)); got != true {
281 t.Errorf("Has(%q) = %v, want %v", "foo", got, true)

pkg/kubeapiserver/options/authentication_test.go1

795:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

pkg/kubeapiserver/options/authentication_test.go:795:6

794
795func TestToAuthenticationConfig_OIDC(t *testing.T) {
796 testCases := []struct {

pkg/registry/core/service/ipallocator/controller/repairip.go1

122:6confusing-namingname newRepairIPAddress differs from NewRepairIPAddress only by capitalization

pkg/registry/core/service/ipallocator/controller/repairip.go:122:6

121// newRepairIPAddress implements NewRepairIPAddress by additionally consuming clock.Clock.
122func newRepairIPAddress(interval time.Duration,
123 client kubernetes.Interface,

pkg/scheduler/framework/plugins/noderesources/resource_allocation_test.go1

637:134confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/noderesources/resource_allocation_test.go:637:134

636// returns (matches, found)
637func (r *resourceAllocationScorer) getCachedDeviceMatch(expression string, driver string, poolName string, deviceName string) (bool, bool) {
638 key := buildDeviceMatchCacheKey(expression, driver, poolName, deviceName)

pkg/registry/flowcontrol/ensurer/strategy.go1

119:6constructor-interface-returnNewObjectOps returns interface ObjectOps[ObjectType] although its concrete result is consistently objectOps[ObjectType]; return the concrete type

pkg/registry/flowcontrol/ensurer/strategy.go:119:6

118
119func NewObjectOps[ObjectType configurationObjectType](client client[ObjectType], cache cache[ObjectType],
120 deepCopy func(ObjectType) ObjectType,

pkg/proxy/conntrack/sysctls.go1

58:6cyclomatic-complexityfunction complexity is 16; maximum is 10

pkg/proxy/conntrack/sysctls.go:58:6

57
58func setSysctls(ctx context.Context, ct conntrackConfigurer, config *kubeproxyconfig.KubeProxyConntrackConfiguration) error {
59 max, err := getConntrackMax(ctx, config, detectNumCPU())

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

127:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.ProofOfPossession is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:127:5

126 PKIXPublicKey: ed25519PubPKIX2,
127 ProofOfPossession: ed25519Proof2,
128 UnverifiedUserAnnotations: map[string]string{"test/foo": "bar"},

pkg/proxy/conntrack/sysctls.go1

191:15discarded-error-resulterror result returned by sys.GetSysctl is discarded

pkg/proxy/conntrack/sysctls.go:191:15

190 sys := sysctl.New()
191 if val, _ := sys.GetSysctl(entry); val != value {
192 logger.Info("Set sysctl", "entry", entry, "value", value)

pkg/kubeapiserver/authorizer/modes/modes.go1

30:2doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/modes/modes.go:30:2

29 ModeWebhook string = "Webhook"
30 // ModeRBAC is the mode to use Role Based Access Control to authorize
31 ModeRBAC string = "RBAC"

pkg/scheduler/framework/runtime/framework.go1

1241:10early-returninvert the condition and return early to reduce nesting

pkg/scheduler/framework/runtime/framework.go:1241:10

1240 return res, status.WithPlugin(pl.Name())
1241 } else if status.Code() == fwk.Unschedulable {
1242 reasons = append(reasons, status.Reasons()...)

pkg/proxy/config/config_test.go1

301:13error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/config/config_test.go:301:13

300 case <-time.After(wait.ForeverTestTimeout):
301 t.Errorf("Timed out. Expected %#v, Got %#v", expectedSlices, slices)
302 return

pkg/kubeapiserver/default_storage_factory_builder.go1

112:32exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/default_storage_factory_builder.go:112:32

111// This method mutates the receiver (StorageFactoryConfig). It must never mutate the inputs.
112func (c *StorageFactoryConfig) Complete(etcdOptions *serveroptions.EtcdOptions) *completedStorageFactoryConfig {
113 c.StorageConfig = etcdOptions.StorageConfig

pkg/proxy/ipvs/ipset/ipset.go1

1:1file-length-limitfile has 537 lines; maximum is 500

pkg/proxy/ipvs/ipset/ipset.go:1:1

1//go:build linux
2

pkg/proxy/ipvs/ipset/testing/fake.go1

83:49flag-parameterboolean parameter ignoreExistErr controls function flow

pkg/proxy/ipvs/ipset/testing/fake.go:83:49

82// CreateSet is part of interface.
83func (f *FakeIPSet) CreateSet(set *ipset.IPSet, ignoreExistErr bool) error {
84 if f.Sets[set.Name] != nil {

pkg/kubeapiserver/options/authentication.go1

1:1formatfile is not formatted

pkg/kubeapiserver/options/authentication.go:1:1

1/*
2Copyright 2016 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/options/authentication.go`

pkg/kubeapiserver/options/authentication_test.go1

795:6function-lengthfunction has 15 statements and 294 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:795:6

794
795func TestToAuthenticationConfig_OIDC(t *testing.T) {
796 testCases := []struct {

pkg/registry/core/service/ipallocator/storage/storage_test.go1

38:6function-result-limitfunction returns 5 values; maximum is 3

pkg/registry/core/service/ipallocator/storage/storage_test.go:38:6

37
38func newStorage(t *testing.T) (*etcd3testing.EtcdTestServer, ipallocator.Interface, allocator.Interface, storage.Interface, factory.DestroyFunc) {
39 etcdStorage, server := registrytest.NewEtcdStorage(t, "")

pkg/proxy/iptables/proxier.go1

158:2import-shadowingidentifier conntrack shadows an imported package

pkg/proxy/iptables/proxier.go:158:2

157 masqueradeMark string
158 conntrack conntrack.Interface
159 nfacct nfacct.Interface

pkg/registry/core/service/storage/transaction_test.go1

142:6increment-decrementuse ++ or -- instead of assigning an addition or subtraction of one

pkg/registry/core/service/storage/transaction_test.go:142:6

141 revert: func() {
142 temp = temp - 1
143 },

pkg/scheduler/backend/cache/cache.go1

812:5inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/scheduler/backend/cache/cache.go:812:5

811 if _, ok := newSum[name]; !ok {
812 newSum[name] = state
813 }

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go1

4260:27inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use strconv.Itoa

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go:4260:27

4259
4260 obj.SetResourceVersion(fmt.Sprintf("%d", resourceVersionCounter))
4261 resourceVersionCounter++

pkg/kubeapiserver/options/authentication_test.go1

356:52insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:356:52

355 expectConfig := kubeauthenticator.Config{
356 APIAudiences: authenticator.Audiences{"http://foo.bar.com"},
357 Anonymous: apiserver.AnonymousAuthConfig{Enabled: false},

pkg/scheduler/framework/preemption/executor_test.go1

821:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/preemption/executor_test.go:821:8

820 if len(tt.expectedDeletedPod) == 0 {
821 if deletedPods.Len() != 0 {
822 // When tt.expectedDeletedPod is empty, we expect no pod to be deleted.

pkg/registry/core/serviceaccount/storage/storage.go1

42:6max-parametersfunction has 9 parameters; maximum is 8

pkg/registry/core/serviceaccount/storage/storage.go:42:6

41// NewREST returns a RESTStorage object that will work against service accounts.
42func NewREST(optsGetter generic.RESTOptionsGetter, issuer token.TokenGenerator, auds authenticator.Audiences, max time.Duration, podStorage, secretStorage, nodeStorage rest.Getter, extendExpiration bool, maxExtendedExpiration time.Duration) (*REST, error) {
43 store := &genericregistry.Store{

pkg/scheduler/apis/config/types.go1

324:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types.go:324:6

323// ExtenderTLSConfig contains settings to enable TLS with extender
324type ExtenderTLSConfig struct {
325 // Server should be accessed without verifying the TLS certificate. For testing only.

pkg/proxy/apis/config/v1alpha1/conversion.go1

39:3modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:39:3

38 default:
39 out.IPTables.MasqueradeAll = in.Linux.MasqueradeAll
40 }

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go1

101:3modifies-value-receiverassignment modifies value receiver m

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go:101:3

100 for _, tmtc := range toMerge {
101 m[tmtc.topologyPair] += tmtc.count
102 }

pkg/proxy/apis/config/validation/validation_test.go1

206:41nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/validation/validation_test.go:206:41

205
206 for name, testCase := range map[string]struct {
207 config kubeproxyconfig.KubeProxyIPTablesConfiguration

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

447:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:447:4

446 if err != nil {
447 return true, nil
448 }

pkg/registry/core/pod/storage/eviction_test.go1

1029:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/core/pod/storage/eviction_test.go:1029:2

1028func (ms *mockStore) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) {
1029 return nil, nil
1030}

pkg/registry/admissionregistration/rest/storage_apiserver.go1

64:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/admissionregistration/rest/storage_apiserver.go:64:4

63 return genericapiserver.APIGroupInfo{}, err
64 } else if len(storageMap) > 0 {
65 apiGroupInfo.VersionedResourcesStorageMap[admissionregistrationv1alpha1.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go1

79:6no-initreplace init with explicit initialization

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go:79:6

78
79func init() {
80 metrics.InitMetrics()

pkg/proxy/nftables/cleanup.go1

38:2no-naked-returnreturn values must be explicit

pkg/proxy/nftables/cleanup.go:38:2

37 }
38 return
39}

pkg/proxy/apis/config/register.go1

28:5no-package-varpackage variables introduce mutable global state

pkg/proxy/apis/config/register.go:28:5

27// SchemeGroupVersion is group version used to register these objects
28var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
29

pkg/kubeapiserver/options/authentication_test.go1

304:25optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication_test.go:304:25

303 errs := options.Validate()
304 if len(errs) > 0 && (!strings.Contains(utilerrors.NewAggregate(errs).Error(), testcase.expectErr) || testcase.expectErr == "") {
305 t.Errorf("Got err: %v, Expected err: %s", errs, testcase.expectErr)

pkg/registry/rbac/rolebinding/strategy.go1

66:2overwritten-before-usethis value of oldRoleBinding is overwritten before use

pkg/registry/rbac/rolebinding/strategy.go:66:2

65 newRoleBinding := obj.(*rbac.RoleBinding)
66 oldRoleBinding := old.(*rbac.RoleBinding)
67

pkg/kubeapiserver/options/options.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/options/options.go:17:9

16
17package options
18

pkg/scheduler/framework/plugins/podtopologyspread/plugin.go1

250:50possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/plugins/podtopologyspread/plugin.go:250:50

249 // Pod is deleted. Return Queue when the deleted Pod has a label that matches with topologySpread's selector.
250 if podLabelsMatchSpreadConstraints(constraints, originalPod.Labels) {
251 logger.V(5).Info("a scheduled pod which matches with the pod's topology spread constraints was deleted, and the pod may be schedulable now",

pkg/proxy/ipvs/proxier.go1

919:12range-value-addresstaking the address of range value ingress can be misleading

pkg/proxy/ipvs/proxier.go:919:12

918 // ipset call
919 entry = &utilipset.Entry{
920 IP: ingress.String(),

pkg/registry/rbac/clusterrolebinding/policybased/storage.go1

94:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/clusterrolebinding/policybased/storage.go:94:7

93
94func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
95 if rbacregistry.EscalationAllowed(ctx) {

pkg/registry/certificates/podcertificaterequest/strategy.go1

99:56redefines-builtin-ididentifier new shadows a predeclared identifier

pkg/registry/certificates/podcertificaterequest/strategy.go:99:56

98
99func (s *Strategy) ValidateUpdate(ctx context.Context, new, old runtime.Object) field.ErrorList {
100 newReq := new.(*certificates.PodCertificateRequest)

pkg/proxy/apis/config/validation/validation_test.go1

528:18redundant-conversionconversion from config.ProxyMode to the identical type is redundant

pkg/proxy/apis/config/validation/validation_test.go:528:18

527 "invalid mode non-existent": {
528 mode: kubeproxyconfig.ProxyMode("non-existing"),
529 expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ProxyMode"), "non-existing", "must be kernelspace or blank (blank means the most-available proxy [currently kernelspace])")},

pkg/proxy/iptables/number_generated_rules_test.go1

26:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/iptables/number_generated_rules_test.go:26:2

25
26 v1 "k8s.io/api/core/v1"
27 discovery "k8s.io/api/discovery/v1"

pkg/proxy/apis/config/validation/validation.go1

315:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/apis/config/validation/validation.go:315:2

314 allErrs := field.ErrorList{}
315 switch {
316 case len(cidrStrings) == 0:

pkg/proxy/util/utils_test.go1

248:8slice-preallocationpreallocate ipStr with capacity len(range source) before appending once per iteration

pkg/proxy/util/utils_test.go:248:8

247
248 var ipStr []string
249 for _, ip := range ipMap[ipFamily] {

pkg/proxy/endpointschangetracker.go1

293:2task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/endpointschangetracker.go:293:2

292func (em EndpointsMap) LocalReadyEndpoints() map[types.NamespacedName]int {
293 // TODO: If this will appear to be computationally expensive, consider
294 // computing this incrementally similarly to endpointsMap.

pkg/kubeapiserver/options/authentication_test.go1

761:24test-parallelismconsider calling t.Parallel() when this subtest begins

pkg/kubeapiserver/options/authentication_test.go:761:24

760 for _, testcase := range testCases {
761 t.Run(testcase.name, func(t *testing.T) {
762 opts := NewBuiltInAuthenticationOptions().WithAnonymous()

pkg/proxy/conntrack/cleanup.go1

170:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/conntrack/cleanup.go:170:1

169// ipFamilyMap maps v1.IPFamily to the corresponding unix constant.
170var ipFamilyMap = map[v1.IPFamily]uint8{
171 v1.IPv4Protocol: unix.AF_INET,

pkg/proxy/winkernel/proxier_test.go1

1828:28unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/proxier_test.go:1828:28

1827
1828 hcnMock := (v4Proxier.hcn).(*fakehcn.HcnMock)
1829 v4Proxier.rootHnsEndpointName = endpointGw

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go1

476:49unexported-returnexported function returns an unexported type

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go:476:49

475
476func (b *plBuilder) WithGeneration(value int64) *plBuilder {
477 b.object.SetGeneration(value)

pkg/proxy/conntrack/sysctls_test.go1

96:53unused-parameterparameter ctx is unused

pkg/proxy/conntrack/sysctls_test.go:96:53

95}
96func (fc *fakeConntracker) SetTCPEstablishedTimeout(ctx context.Context, seconds int) error {
97 fc.called = append(fc.called, fmt.Sprintf("SetTCPEstablishedTimeout(%d)", seconds))

pkg/proxy/healthcheck/healthcheck_test.go1

103:7unused-receiverreceiver fake is unused

pkg/proxy/healthcheck/healthcheck_test.go:103:7

102
103func (fake *fakeHTTPServerFactory) New(handler http.Handler) httpServer {
104 return &fakeHTTPServer{

pkg/proxy/config/config.go1

321:43use-anyuse any instead of interface{}

pkg/proxy/config/config.go:321:43

320
321func (c *NodeConfig) handleChangeNode(obj interface{}) {
322 node, ok := obj.(*v1.Node)

pkg/kubeapiserver/options/authentication.go1

855:34use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication.go:855:34

854 if o.OIDC != nil && o.OIDC.FlagsSet && (len(o.OIDC.IssuerURL) == 0 || len(o.OIDC.ClientID) == 0) {
855 allErrors = append(allErrors, fmt.Errorf("oidc-issuer-url and oidc-client-id must be specified together when any oidc-* flags are set"))
856 }

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go1

345:2use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go:345:2

344 // higher importance victims first.
345 sort.Slice(potentialVictims, func(i, j int) bool {
346 return pl.MoreImportantVictim(potentialVictims[i], potentialVictims[j])

pkg/proxy/endpointschangetracker_test.go1

465:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:465:2

464 }
465 complexBefore4_s2 := func(eps *discovery.EndpointSlice) {
466 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/authentication_test.go1

113:23add-constantstring literal "http://foo.bar.com" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:113:23

112 testSA: &ServiceAccountAuthenticationOptions{
113 Issuers: []string{"http://foo.bar.com"},
114 },

pkg/scheduler/backend/heap/heap_test.go1

289:44boolean-literal-comparisonomit the boolean literal from the logical expression

pkg/scheduler/backend/heap/heap_test.go:289:44

288 h.Delete(mkHeapObj("foo", 0, 1))
289 if got := h.Has(mkHeapObj("foo", 0, 1)); got != false {
290 t.Errorf("Has(%q) = %v, want %v", "foo", got, false)

pkg/kubeapiserver/options/authentication_test.go1

1090:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

pkg/kubeapiserver/options/authentication_test.go:1090:6

1089
1090func TestValidateOIDCOptions(t *testing.T) {
1091 testCases := []struct {

pkg/registry/core/service/ipallocator/ipallocator.go1

189:21confusing-namingname allocateService differs from AllocateService only by capitalization

pkg/registry/core/service/ipallocator/ipallocator.go:189:21

188
189func (a *Allocator) allocateService(svc *api.Service, ip net.IP, dryRun bool) error {
190 if !a.ready.Load() || !a.ipAddressSynced() {

pkg/scheduler/framework/plugins/noderesources/resource_allocation_test.go1

758:148confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/noderesources/resource_allocation_test.go:758:148

757// getCachedNodeMatch checks the cache for a NodeMatches result
758func (r *resourceAllocationScorer) getCachedNodeMatch(nodeName string, nodeNameToMatch string, allNodesMatch bool, nodeSelectorHash string) (bool, bool) {
759 key := buildNodeMatchCacheKey(nodeName, nodeNameToMatch, allNodesMatch, nodeSelectorHash)

pkg/registry/flowcontrol/ensurer/strategy.go1

142:6constructor-interface-returnNewSuggestedEnsureStrategy returns interface EnsureStrategy[ObjectType] although its concrete result is consistently *strategy[ObjectType]; return the concrete type

pkg/registry/flowcontrol/ensurer/strategy.go:142:6

141// NewSuggestedEnsureStrategy returns an EnsureStrategy for suggested config objects
142func NewSuggestedEnsureStrategy[ObjectType configurationObjectType]() EnsureStrategy[ObjectType] {
143 return &strategy[ObjectType]{

pkg/proxy/endpointschangetracker.go1

193:24cyclomatic-complexityfunction complexity is 11; maximum is 10

pkg/proxy/endpointschangetracker.go:193:24

192// changes map.
193func (em EndpointsMap) Update(ect *EndpointsChangeTracker) UpdateEndpointsMapResult {
194 result := UpdateEndpointsMapResult{

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

166:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.PKIXPublicKey is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty. Signer implementations should extract the public key from the StubPKCS10Request field.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:166:5

165 MaxExpirationSeconds: ptr.To[int32](86400),
166 PKIXPublicKey: ed25519PubPKIX1,
167 ProofOfPossession: ed25519Proof1,

pkg/proxy/healthcheck/healthcheck_test.go1

159:2discarded-error-resulterror result returned by hcs.SyncServices is discarded

pkg/proxy/healthcheck/healthcheck_test.go:159:2

158 // sync nothing
159 hcs.SyncServices(nil)
160 if len(hcs.services) != 0 {

pkg/kubeapiserver/authorizer/modes/modes.go1

36:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/modes/modes.go:36:1

35
36// AuthorizationModeChoices is the list of supported authorization modes
37var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABAC, ModeWebhook, ModeRBAC, ModeNode}

pkg/scheduler/framework/runtime/framework.go1

2041:4early-returninvert the condition and return early to reduce nesting

pkg/scheduler/framework/runtime/framework.go:2041:4

2040 }
2041 if status.IsWait() {
2042 // Not allowed to be greater than maxTimeout.

pkg/proxy/config/config_test.go1

504:13error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/config/config_test.go:504:13

503 case <-time.After(wait.ForeverTestTimeout):
504 t.Errorf("Timed out. Expected %#v, Got %#v", expectedNodes, nodes)
505 return

pkg/kubeapiserver/options/admission.go1

39:6exported-declaration-commentexported type should have a comment beginning with its name

pkg/kubeapiserver/options/admission.go:39:6

38// It is a wrap of generic AdmissionOptions.
39type AdmissionOptions struct {
40 // GenericAdmission holds the generic admission options.

pkg/proxy/ipvs/ipset/ipset_test.go1

1:1file-length-limitfile has 1768 lines; maximum is 500

pkg/proxy/ipvs/ipset/ipset_test.go:1:1

1//go:build linux
2

pkg/proxy/ipvs/ipset/testing/fake.go1

98:62flag-parameterboolean parameter ignoreExistErr controls function flow

pkg/proxy/ipvs/ipset/testing/fake.go:98:62

97// AddEntry is part of interface.
98func (f *FakeIPSet) AddEntry(entry string, set *ipset.IPSet, ignoreExistErr bool) error {
99 if f.Entries[set.Name].Has(entry) {

pkg/kubeapiserver/options/authentication_test.go2

1:1formatfile is not formatted

pkg/kubeapiserver/options/authentication_test.go:1:1

1/*
2Copyright 2018 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/options/authentication_test.go`
1090:6function-lengthfunction has 15 statements and 156 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:1090:6

1089
1090func TestValidateOIDCOptions(t *testing.T) {
1091 testCases := []struct {

pkg/registry/core/service/portallocator/storage/storage_test.go1

43:6function-result-limitfunction returns 5 values; maximum is 3

pkg/registry/core/service/portallocator/storage/storage_test.go:43:6

42
43func newStorage(t *testing.T) (*etcd3testing.EtcdTestServer, portallocator.Interface, allocator.Interface, storage.Interface, factory.DestroyFunc) {
44 etcdStorage, server := registrytest.NewEtcdStorage(t, "")

pkg/proxy/iptables/proxier.go1

159:2import-shadowingidentifier nfacct shadows an imported package

pkg/proxy/iptables/proxier.go:159:2

158 conntrack conntrack.Interface
159 nfacct nfacct.Interface
160 localDetector proxyutil.LocalTrafficDetector

pkg/scheduler/backend/cache/cache_test.go1

1892:6inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/scheduler/backend/cache/cache_test.go:1892:6

1891 }
1892 imageStates[name] = state
1893 } else {

pkg/scheduler/framework/preemption/executor_test.go1

181:9inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use the string value directly

pkg/scheduler/framework/preemption/executor_test.go:181:9

180 for _, tt := range tests {
181 t.Run(fmt.Sprintf("%v", tt.name), func(t *testing.T) {
182

pkg/kubeapiserver/options/authentication_test.go1

379:41insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:379:41

378 ServiceAccountLookup: true,
379 ServiceAccountIssuers: []string{"http://foo.bar.com"},
380 WebhookTokenAuthnConfigFile: "/token-webhook-config",

pkg/scheduler/framework/preemption/executor_test.go1

831:8max-control-nestingcontrol-flow nesting exceeds 5 levels

pkg/scheduler/framework/preemption/executor_test.go:831:8

830 for _, podName := range tt.expectedDeletedPod {
831 if deletedPods.Has(podName) ||
832 // If podName is empty, we expect no pod to be deleted.

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go1

4066:6max-parametersfunction has 10 parameters; maximum is 8

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go:4066:6

4065
4066func setup(tCtx ktesting.TContext, args *config.DynamicResourcesArgs, nodes []*v1.Node, claims []*resourceapi.ResourceClaim, classes []*resourceapi.DeviceClass, podGroups []*schedulingapi.PodGroup, objs []apiruntime.Object, features feature.Features, failPatch bool, apiReactors []cgotesting.Reactor) (result *testContext) {
4067 tCtx.Helper()

pkg/scheduler/apis/config/types_pluginargs.go1

131:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types_pluginargs.go:131:6

130// UtilizationShapePoint represents a single point of a priority function shape.
131type UtilizationShapePoint struct {
132 // Utilization (x axis). Valid values are 0 to 100. Fully utilized node maps to 100.

pkg/proxy/apis/config/v1alpha1/conversion.go1

44:3modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:44:3

43 case kubeproxyconfig.ProxyModeIPVS:
44 out.IPVS.SyncPeriod = in.SyncPeriod
45 out.IPVS.MinSyncPeriod = in.MinSyncPeriod

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go1

114:3modifies-value-receiverassignment modifies value receiver m

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go:114:3

113 pair := topologyPair{key: tk, value: tv}
114 m[pair] += value
115 // value could be negative, hence we delete the entry if it is down to zero.

pkg/proxy/apis/config/validation/validation_test.go1

232:41nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/validation/validation_test.go:232:41

231 newPath := field.NewPath("KubeProxyConfiguration")
232 for name, testCase := range map[string]struct {
233 config kubeproxyconfig.KubeProxyIPVSConfiguration

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

459:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:459:4

458 if err != nil {
459 return false, nil
460 }

pkg/registry/core/pod/storage/eviction_test.go1

1033:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/core/pod/storage/eviction_test.go:1033:2

1032func (ms *mockStore) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
1033 return nil, nil
1034}

pkg/registry/apiserverinternal/rest/storage.go1

39:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/apiserverinternal/rest/storage.go:39:4

38 return genericapiserver.APIGroupInfo{}, err
39 } else if len(storageMap) > 0 {
40 apiGroupInfo.VersionedResourcesStorageMap[apiserverv1alpha1.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/plugins/gangscheduling/gangscheduling_test.go1

46:6no-initreplace init with explicit initialization

pkg/scheduler/framework/plugins/gangscheduling/gangscheduling_test.go:46:6

45
46func init() {
47 // This is required for tests where cache is initialized, and cache attempts to update metrics.

pkg/proxy/nftables/proxier.go1

1072:3no-naked-returnreturn values must be explicit

pkg/proxy/nftables/proxier.go:1072:3

1071 proxier.logger.V(2).Info("Not syncing nftables until Services and Endpoints have been received from master")
1072 return
1073 }

pkg/proxy/apis/config/register.go1

32:2no-package-varpackage variables introduce mutable global state

pkg/proxy/apis/config/register.go:32:2

31 // SchemeBuilder is the scheme builder with scheme init functions to run for this API package
32 SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
33 // AddToScheme is a global function that registers this API group & version to a scheme

pkg/kubeapiserver/options/authentication_test.go1

1234:25optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authentication_test.go:1234:25

1233 errs := opts.Validate()
1234 if len(errs) > 0 && (!strings.Contains(utilerrors.NewAggregate(errs).Error(), tt.expectErr) || tt.expectErr == "") {
1235 t.Errorf("Got err: %v, Expected err: %s", errs, tt.expectErr)

pkg/kubeapiserver/options/plugins.go1

17:9package-commentspackage should have a documentation comment

pkg/kubeapiserver/options/plugins.go:17:9

16
17package options
18

pkg/scheduler/framework/preemption/podgrouppreemption_test.go1

1462:26possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/preemption/podgrouppreemption_test.go:1462:26

1461 gotNames := sets.Set[string]{}
1462 for _, p := range res.victims.Pods {
1463 gotNames.Insert(p.Name)

pkg/proxy/ipvs/proxier.go1

954:14range-value-addresstaking the address of range value cidr can be misleading

pkg/proxy/ipvs/proxier.go:954:14

953 // ipset call
954 entry = &utilipset.Entry{
955 IP: ingress.String(),

pkg/registry/rbac/clusterrolebinding/policybased/storage.go1

133:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/clusterrolebinding/policybased/storage.go:133:7

132
133func (s *Storage) GetSingularName() string {
134 snp, ok := s.StandardStorage.(rest.SingularNameProvider)

pkg/registry/certificates/podcertificaterequest/strategy.go1

150:62redefines-builtin-ididentifier new shadows a predeclared identifier

pkg/registry/certificates/podcertificaterequest/strategy.go:150:62

149
150func (s *StatusStrategy) ValidateUpdate(ctx context.Context, new, old runtime.Object) field.ErrorList {
151 oldPCR := old.(*certificates.PodCertificateRequest)

pkg/proxy/apis/config/validation/validation_test.go1

555:72redundant-conversionconversion from int64 to the identical type is redundant

pkg/proxy/apis/config/validation/validation_test.go:555:72

554 ccc: componentbaseconfig.ClientConnectionConfiguration{Burst: -5},
555 expectedErrs: field.ErrorList{field.Invalid(newPath.Child("Burst"), int64(-5), "must be greater than or equal to 0")},
556 },

pkg/proxy/iptables/proxier.go1

34:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/iptables/proxier.go:34:2

33
34 v1 "k8s.io/api/core/v1"
35 discovery "k8s.io/api/discovery/v1"

pkg/proxy/apis/config/validation/validation.go1

338:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/apis/config/validation/validation.go:338:2

337 allErrs := field.ErrorList{}
338 switch mode {
339 case kubeproxyconfig.LocalModeBridgeInterface:

pkg/proxy/util/utils_test.go1

358:8slice-preallocationpreallocate cidrStr with capacity len(range source) before appending once per iteration

pkg/proxy/util/utils_test.go:358:8

357
358 var cidrStr []string
359 for _, cidr := range cidrMap[ipFamily] {

pkg/proxy/endpointslicecache.go1

177:4task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/endpointslicecache.go:177:4

176 }
177 // TODO: handle nil ports to mean "all"
178 if port.Port == nil || *port.Port == int32(0) {

pkg/kubeapiserver/options/authentication_test.go1

795:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/authentication_test.go:795:6

794
795func TestToAuthenticationConfig_OIDC(t *testing.T) {
796 testCases := []struct {

pkg/proxy/conntrack/conntrack.go1

48:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/conntrack/conntrack.go:48:1

47
48var _ Interface = &conntracker{}
49

pkg/proxy/winkernel/proxier_test.go1

2094:26unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/proxier_test.go:2094:26

2093 // Pre-populate the local HNS endpoint at sharedEPIP (as CNI would create it)
2094 hcnMock := (proxier.hcn).(*fakehcn.HcnMock)
2095 hcnMock.PopulateQueriedEndpoints(endpointLocal1, networkId, sharedEPIP, macAddressLocal1, prefixLen)

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go1

481:60unexported-returnexported function returns an unexported type

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go:481:60

480
481func (b *plBuilder) WithAutoUpdateAnnotation(value string) *plBuilder {
482 setAnnotation(b.object, value)

pkg/proxy/conntrack/sysctls_test.go1

100:51unused-parameterparameter ctx is unused

pkg/proxy/conntrack/sysctls_test.go:100:51

99}
100func (fc *fakeConntracker) SetTCPCloseWaitTimeout(ctx context.Context, seconds int) error {
101 fc.called = append(fc.called, fmt.Sprintf("SetTCPCloseWaitTimeout(%d)", seconds))

pkg/proxy/healthcheck/healthcheck_test.go1

113:7unused-receiverreceiver fake is unused

pkg/proxy/healthcheck/healthcheck_test.go:113:7

112
113func (fake *fakeHTTPServer) Serve(listener net.Listener) error {
114 return nil // Cause the goroutine to return

pkg/proxy/config/config.go1

333:43use-anyuse any instead of interface{}

pkg/proxy/config/config.go:333:43

332
333func (c *NodeConfig) handleDeleteNode(obj interface{}) {
334 node, ok := obj.(*v1.Node)

pkg/kubeapiserver/options/authentication.go1

865:33use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication.go:865:33

864 if o.OIDC != nil && o.OIDC.FlagsSet {
865 allErrors = append(allErrors, fmt.Errorf("authentication-config file and oidc-* flags are mutually exclusive"))
866 }

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go1

396:3use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go:396:3

395 if len(violatingVictims) != 0 && len(nonViolatingVictims) != 0 {
396 sort.Slice(victims, func(i, j int) bool { return pl.MoreImportantVictim(victims[i], victims[j]) })
397 }

pkg/proxy/endpointschangetracker_test.go1

476:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:476:2

475 }
476 complexAfter1_s1 := func(eps *discovery.EndpointSlice) {
477 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/authentication_test.go2

123:20add-constantstring literal "testClientID" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:123:20

122 IssuerURL: "https://testIssuerURL",
123 ClientID: "testClientID",
124 FlagsSet: true,
1612:6cognitive-complexityfunction has cognitive complexity 32; maximum is 7

pkg/kubeapiserver/options/authentication_test.go:1612:6

1611
1612func TestToAuthenticationConfigForServiceAccount(t *testing.T) {
1613

pkg/registry/core/service/ipallocator/ipallocator.go1

237:21confusing-namingname allocateNextService differs from AllocateNextService only by capitalization

pkg/registry/core/service/ipallocator/ipallocator.go:237:21

236// It starts allocating from a random IP within each range.
237func (a *Allocator) allocateNextService(svc *api.Service, dryRun bool) (net.IP, error) {
238 if !a.ready.Load() || !a.ipAddressSynced() {

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go1

499:127confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go:499:127

498// the information of the CSI driver that the plugin has been migrated to.
499func (pl *CSILimits) getCSIDriverInfo(logger klog.Logger, csiNode *storagev1.CSINode, pvc *v1.PersistentVolumeClaim) (string, string) {
500 pvName := pvc.Spec.VolumeName

pkg/registry/flowcontrol/ensurer/strategy.go1

150:6constructor-interface-returnNewMandatoryEnsureStrategy returns interface EnsureStrategy[ObjectType] although its concrete result is consistently *strategy[ObjectType]; return the concrete type

pkg/registry/flowcontrol/ensurer/strategy.go:150:6

149// NewMandatoryEnsureStrategy returns an EnsureStrategy for mandatory config objects
150func NewMandatoryEnsureStrategy[ObjectType configurationObjectType]() EnsureStrategy[ObjectType] {
151 return &strategy[ObjectType]{

pkg/proxy/endpointschangetracker_test.go1

186:6cyclomatic-complexityfunction complexity is 13; maximum is 10

pkg/proxy/endpointschangetracker_test.go:186:6

185
186func TestUpdateEndpointsMap(t *testing.T) {
187 emptyEndpoint := func(eps *discovery.EndpointSlice) {

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

167:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.ProofOfPossession is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:167:5

166 PKIXPublicKey: ed25519PubPKIX1,
167 ProofOfPossession: ed25519Proof1,
168 UnverifiedUserAnnotations: map[string]string{"test/foo": "bar"},

pkg/proxy/healthcheck/healthcheck_test.go1

163:2discarded-error-resulterror result returned by hcs.SyncEndpoints is discarded

pkg/proxy/healthcheck/healthcheck_test.go:163:2

162 }
163 hcs.SyncEndpoints(nil)
164 if len(hcs.services) != 0 {

pkg/kubeapiserver/authorizer/modes/modes.go1

39:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/authorizer/modes/modes.go:39:1

38
39// IsValidAuthorizationMode returns true if the given authorization mode is a valid one for the apiserver
40func IsValidAuthorizationMode(authzMode string) bool {

pkg/scheduler/framework/runtime/registry_test.go1

80:3early-returninvert the condition and return early to reduce nesting

pkg/scheduler/framework/runtime/registry_test.go:80:3

79 for name, pluginFactory := range registryY {
80 if val, ok := registryX[name]; ok {
81 p1, _ := pluginFactory(nil, nil, nil)

pkg/proxy/config/config_test.go1

653:13error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/config/config_test.go:653:13

652 case <-time.After(wait.ForeverTestTimeout):
653 t.Errorf("Timed out. Expected %#v, Got %#v", expectedServiceCIDRs, serviceCIDRs)
654 return

pkg/kubeapiserver/options/admission.go1

56:6exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/options/admission.go:56:6

55// Servers that do care can overwrite/append that field after creation.
56func NewAdmissionOptions() *AdmissionOptions {
57 options := genericoptions.NewAdmissionOptions()

pkg/proxy/ipvs/proxier.go2

1:1file-length-limitfile has 1772 lines; maximum is 500

pkg/proxy/ipvs/proxier.go:1:1

1//go:build linux
2
122:2flag-parameterboolean parameter initOnly controls function flow

pkg/proxy/ipvs/proxier.go:122:2

121 healthzServer *healthcheck.ProxyHealthServer,
122 initOnly bool,
123) (proxy.Provider, error) {

pkg/kubeapiserver/options/authorization.go1

1:1formatfile is not formatted

pkg/kubeapiserver/options/authorization.go:1:1

1/*
2Copyright 2016 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/options/authorization.go`

pkg/kubeapiserver/options/authentication_test.go1

1247:6function-lengthfunction has 29 statements and 336 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:1247:6

1246
1247func TestLoadAuthenticationConfig(t *testing.T) {
1248 testCases := []struct {

pkg/registry/core/service/storage/storage.go1

74:6function-result-limitfunction returns 4 values; maximum is 3

pkg/registry/core/service/storage/storage.go:74:6

73// NewREST returns a REST object that will work against services.
74func NewREST(
75 optsGetter generic.RESTOptionsGetter,

pkg/proxy/ipvs/ipset/ipset.go1

423:2import-shadowingidentifier bytes shadows an imported package

pkg/proxy/ipvs/ipset/ipset.go:423:2

422 cmd.SetStdin(bytes.NewReader([]byte{}))
423 bytes, err := cmd.CombinedOutput()
424 if err != nil {

pkg/scheduler/backend/cache/node_tree.go1

60:3inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/scheduler/backend/cache/node_tree.go:60:3

59 }
60 nt.tree[zone] = append(na, n.Name)
61 } else {

pkg/scheduler/framework/preemption/executor_test.go1

1841:9inefficient-sprintffmt.Sprintf is unnecessary for this conversion; use the string value directly

pkg/scheduler/framework/preemption/executor_test.go:1841:9

1840 for _, tt := range tests {
1841 t.Run(fmt.Sprintf("%v", tt.name), func(t *testing.T) {
1842

pkg/kubeapiserver/options/authentication_test.go1

477:36insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:477:36

476 Lookup: true,
477 Issuers: []string{"http://foo.bar.com"},
478 JWKSURI: "https://qux.com",

pkg/scheduler/framework/plugins/volumebinding/binder.go1

243:6max-parametersfunction has 11 parameters; maximum is 8

pkg/scheduler/framework/plugins/volumebinding/binder.go:243:6

242// capacityCheck determines how storage capacity is checked (CSIStorageCapacity feature).
243func NewVolumeBinder(
244 logger klog.Logger,

pkg/scheduler/apis/config/types_pluginargs.go1

139:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types_pluginargs.go:139:6

138// ResourceSpec represents single resource.
139type ResourceSpec struct {
140 // Name of the resource.

pkg/proxy/apis/config/v1alpha1/conversion.go1

45:3modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:45:3

44 out.IPVS.SyncPeriod = in.SyncPeriod
45 out.IPVS.MinSyncPeriod = in.MinSyncPeriod
46 case kubeproxyconfig.ProxyModeNFTables:

pkg/scheduler/framework/plugins/interpodaffinity/scoring.go1

55:5modifies-value-receiverassignment modifies value receiver m

pkg/scheduler/framework/plugins/interpodaffinity/scoring.go:55:5

54 if m[term.TopologyKey] == nil {
55 m[term.TopologyKey] = make(map[string]int64)
56 }

pkg/proxy/apis/config/validation/validation_test.go1

272:41nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/validation/validation_test.go:272:41

271 newPath := field.NewPath("KubeProxyConfiguration")
272 for name, testCase := range map[string]struct {
273 config kubeproxyconfig.KubeProxyLinuxConfiguration

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

508:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:508:4

507 t.Logf("unexpected error %v", err)
508 return false, nil
509 }

pkg/registry/core/pod/storage/eviction_test.go1

1041:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/core/pod/storage/eviction_test.go:1041:2

1040func (ms *mockStore) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) {
1041 return nil, nil
1042}

pkg/registry/apps/rest/storage_apps.go1

45:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/apps/rest/storage_apps.go:45:4

44 return genericapiserver.APIGroupInfo{}, err
45 } else if len(storageMap) > 0 {
46 apiGroupInfo.VersionedResourcesStorageMap[appsapiv1.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/plugins/interpodaffinity/filtering_test.go1

47:6no-initreplace init with explicit initialization

pkg/scheduler/framework/plugins/interpodaffinity/filtering_test.go:47:6

46
47func init() {
48 metrics.Register()

pkg/proxy/nftables/proxier.go1

1734:3no-naked-returnreturn values must be explicit

pkg/proxy/nftables/proxier.go:1734:3

1733 proxier.logFailure(tx)
1734 return
1735 }

pkg/proxy/apis/config/register.go1

34:2no-package-varpackage variables introduce mutable global state

pkg/proxy/apis/config/register.go:34:2

33 // AddToScheme is a global function that registers this API group & version to a scheme
34 AddToScheme = SchemeBuilder.AddToScheme
35)

pkg/kubeapiserver/options/authorization.go1

199:10optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authorization.go:199:10

198
199 return fs.Changed(authorizationModeFlag) ||
200 fs.Changed(authorizationWebhookConfigFileFlag) ||

pkg/proxy/apis/config/doc.go1

20:9package-commentspackage should have a documentation comment

pkg/proxy/apis/config/doc.go:20:9

19
20package config
21

pkg/scheduler/framework/preemption/podgrouppreemption_test.go1

1469:11possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/preemption/podgrouppreemption_test.go:1469:11

1468 }
1469 if res.numPodGroupDisruptions != tt.expectedNumPodGroupDisruptions {
1470 t.Errorf("numPodGroupDisruptions mismatch. Want %d, Got %d", tt.expectedNumPodGroupDisruptions, res.numPodGroupDisruptions)

pkg/proxy/ipvs/proxier.go1

954:14range-value-addresstaking the address of range value ingress can be misleading

pkg/proxy/ipvs/proxier.go:954:14

953 // ipset call
954 entry = &utilipset.Entry{
955 IP: ingress.String(),

pkg/registry/rbac/role/policybased/storage.go1

67:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/role/policybased/storage.go:67:7

66
67func (s *Storage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
68 if rbacregistry.EscalationAllowed(ctx) || rbacregistry.RoleEscalationAuthorized(ctx, s.authorizer) {

pkg/registry/core/pod/strategy.go1

392:40redefines-builtin-ididentifier new shadows a predeclared identifier

pkg/registry/core/pod/strategy.go:392:40

391
392func dropNonResizeUpdatesForContainers(new, old []api.Container) []api.Container {
393 if len(new) == 0 {

pkg/proxy/conntrack/cleanup.go1

84:29redundant-conversionconversion from int to the identical type is redundant

pkg/proxy/conntrack/cleanup.go:84:29

83 if endpoint.IsServing() {
84 portStr := strconv.Itoa(int(endpoint.Port()))
85 endpoints.Insert(net.JoinHostPort(endpoint.IP(), portStr))

pkg/proxy/iptables/proxier_test.go1

38:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/iptables/proxier_test.go:38:2

37
38 v1 "k8s.io/api/core/v1"
39 discovery "k8s.io/api/discovery/v1"

pkg/proxy/endpointschangetracker_test.go1

1059:5single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/endpointschangetracker_test.go:1059:5

1058 prev, curr := tc.previousEndpointSlices[i], tc.currentEndpointSlices[i]
1059 switch {
1060 case prev == nil && curr == nil:

pkg/proxy/util/utils_test.go1

362:8slice-preallocationpreallocate cidrStrOther with capacity len(range source) before appending once per iteration

pkg/proxy/util/utils_test.go:362:8

361 }
362 var cidrStrOther []string
363 for _, cidr := range cidrMap[otherIPFamily] {

pkg/proxy/iptables/proxier_test.go1

85:2task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/iptables/proxier_test.go:85:2

84func NewFakeProxier(ipt utiliptables.Interface) *Proxier {
85 // TODO: Call NewProxier after refactoring out the goroutine
86 // invocation into a Run() method.

pkg/kubeapiserver/options/authentication_test.go1

1066:24test-parallelismconsider calling t.Parallel() when this subtest begins

pkg/kubeapiserver/options/authentication_test.go:1066:24

1065 for _, testcase := range testCases {
1066 t.Run(testcase.name, func(t *testing.T) {
1067 opts := NewBuiltInAuthenticationOptions().WithOIDC()

pkg/proxy/conntrack/fake.go1

36:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/conntrack/fake.go:36:1

35
36var _ netlinkHandler = (*fakeHandler)(nil)
37

pkg/proxy/winkernel/proxier_test.go1

2256:26unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/proxier_test.go:2256:26

2255 // Pre-populate the local HNS endpoint (as CNI would create it).
2256 hcnMock := (proxier.hcn).(*fakehcn.HcnMock)
2257 hcnMock.PopulateQueriedEndpoints(endpointLocal1, networkId, localIP, macAddressLocal1, prefixLen)

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go1

486:65unexported-returnexported function returns an unexported type

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go:486:65

485
486func (b *plBuilder) WithLimited(nominalConcurrencyShares int32) *plBuilder {
487 b.object.Spec.Type = flowcontrolv1.PriorityLevelEnablementLimited

pkg/proxy/conntrack/sysctls_test.go1

104:44unused-parameterparameter ctx is unused

pkg/proxy/conntrack/sysctls_test.go:104:44

103}
104func (fc *fakeConntracker) SetTCPBeLiberal(ctx context.Context, value int) error {
105 fc.called = append(fc.called, fmt.Sprintf("SetTCPBeLiberal(%d)", value))

pkg/proxy/healthcheck/healthcheck_test.go1

117:7unused-receiverreceiver fake is unused

pkg/proxy/healthcheck/healthcheck_test.go:117:7

116
117func (fake *fakeHTTPServer) Close() error {
118 return nil

pkg/proxy/config/config.go1

378:22use-anyuse any instead of interface{}

pkg/proxy/config/config.go:378:22

377 cache.ResourceEventHandlerFuncs{
378 AddFunc: func(obj interface{}) {
379 result.handleServiceCIDREvent(nil, obj)

pkg/kubeapiserver/options/authentication.go1

897:15use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication.go:897:15

896 if len(data) == 0 {
897 return nil, fmt.Errorf("empty config data")
898 }

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go1

1242:4use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go:1242:4

1241 }
1242 sort.Slice(nodeInfos, func(i, j int) bool {
1243 return nodeInfos[i].Node().Name < nodeInfos[j].Node().Name

pkg/proxy/endpointschangetracker_test.go1

488:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:488:2

487 }
488 complexAfter1_s2 := func(eps *discovery.EndpointSlice) {
489 eps.Endpoints = []discovery.Endpoint{{

pkg/kubeapiserver/options/authentication_test.go1

215:24add-constantstring literal "cert" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:215:24

214 testSA: &ServiceAccountAuthenticationOptions{
215 KeyFiles: []string{"cert", "key"},
216 Issuers: []string{"http://foo.bar.com"},

pkg/kubeapiserver/options/authorization.go1

97:39cognitive-complexityfunction has cognitive complexity 18; maximum is 7

pkg/kubeapiserver/options/authorization.go:97:39

96// Validate checks invalid config combination
97func (o *BuiltInAuthorizationOptions) Validate() []error {
98 if o == nil {

pkg/registry/core/service/ipallocator/ipallocator.go1

375:21confusing-namingname release differs from Release only by capitalization

pkg/registry/core/service/ipallocator/ipallocator.go:375:21

374
375func (a *Allocator) release(ip net.IP, dryRun bool) error {
376 if dryRun {

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go1

552:133confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/nodevolumelimits/csi.go:552:133

551// getCSIDriverInfoFromSC returns the CSI driver name and a random volume ID of a given PVC's StorageClass.
552func (pl *CSILimits) getCSIDriverInfoFromSC(logger klog.Logger, csiNode *storagev1.CSINode, pvc *v1.PersistentVolumeClaim) (string, string) {
553 namespace := pvc.Namespace

pkg/registry/rbac/clusterrole/registry.go1

42:6constructor-interface-returnNewRegistry returns interface Registry although its concrete result is consistently *storage; return the concrete type

pkg/registry/rbac/clusterrole/registry.go:42:6

41// types will panic.
42func NewRegistry(s rest.StandardStorage) Registry {
43 return &storage{s}

pkg/proxy/endpointschangetracker_test.go1

1612:6cyclomatic-complexityfunction complexity is 11; maximum is 10

pkg/proxy/endpointschangetracker_test.go:1612:6

1611
1612func compareEndpointsMapsStr(t *testing.T, newMap EndpointsMap, expected map[ServicePortName][]*BaseEndpointInfo) {
1613 t.Helper()

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

221:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.PKIXPublicKey is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty. Signer implementations should extract the public key from the StubPKCS10Request field.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:221:5

220 MaxExpirationSeconds: ptr.To[int32](86400),
221 PKIXPublicKey: ed25519PubPKIX1,
222 ProofOfPossession: ed25519Proof1,

pkg/proxy/healthcheck/healthcheck_test.go1

169:2discarded-error-resulterror result returned by hcs.SyncEndpoints is discarded

pkg/proxy/healthcheck/healthcheck_test.go:169:2

168 // sync unknown endpoints, should be dropped
169 hcs.SyncEndpoints(map[types.NamespacedName]int{mknsn("a", "b"): 93})
170 if len(hcs.services) != 0 {

pkg/kubeapiserver/options/admission.go1

70:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/options/admission.go:70:1

69
70// AddFlags adds flags related to admission for kube-apiserver to the specified FlagSet
71func (a *AdmissionOptions) AddFlags(fs *pflag.FlagSet) {

pkg/scheduler/testing/framework/fake_extender.go1

326:10early-returninvert the condition and return early to reduce nesting

pkg/scheduler/testing/framework/fake_extender.go:326:10

325 failedNodesMap[node.Node().Name] = fmt.Sprintf("FakeExtender: node %q failed", node.Node().Name)
326 } else if status.Code() == fwk.UnschedulableAndUnresolvable {
327 failedAndUnresolvableMap[node.Node().Name] = fmt.Sprintf("FakeExtender: node %q failed and unresolvable", node.Node().Name)

pkg/proxy/conntrack/conntrack_test.go1

155:14error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/conntrack/conntrack_test.go:155:14

154 if n != tc.expectedDeleted {
155 t.Errorf("DeleteEntries() = %d, want %d", n, tc.expectedDeleted)
156 }

pkg/kubeapiserver/options/admission.go1

91:28exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/options/admission.go:91:28

90// Kube-apiserver verifies PluginNames and then call generic AdmissionOptions.Validate.
91func (a *AdmissionOptions) Validate() []error {
92 if a == nil {

pkg/proxy/ipvs/proxier_test.go1

1:1file-length-limitfile has 5621 lines; maximum is 500

pkg/proxy/ipvs/proxier_test.go:1:1

1//go:build linux
2

pkg/proxy/ipvs/proxier.go1

255:2flag-parameterboolean parameter initOnly controls function flow

pkg/proxy/ipvs/proxier.go:255:2

254 healthzServer *healthcheck.ProxyHealthServer,
255 initOnly bool,
256) (*Proxier, error) {

pkg/kubeapiserver/options/authorization_test.go1

1:1formatfile is not formatted

pkg/kubeapiserver/options/authorization_test.go:1:1

1/*
2Copyright 2018 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/options/authorization_test.go`

pkg/kubeapiserver/options/authentication_test.go1

1612:6function-lengthfunction has 41 statements and 154 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authentication_test.go:1612:6

1611
1612func TestToAuthenticationConfigForServiceAccount(t *testing.T) {
1613

pkg/scheduler/backend/cache/snapshot_test.go1

1159:6function-result-limitfunction returns 6 values; maximum is 3

pkg/scheduler/backend/cache/snapshot_test.go:1159:6

1158// simplifySnapshot for comparison in unit tests
1159func simplifySnapshot(s *Snapshot) (map[string][]string, []string, []string, []string, map[string]int, map[string][]string) {
1160 nodeInfoMap := make(map[string][]string)

pkg/proxy/ipvs/proxier.go1

186:2import-shadowingidentifier conntrack shadows an imported package

pkg/proxy/ipvs/proxier.go:186:2

185 ipset utilipset.Interface
186 conntrack conntrack.Interface
187 masqueradeAll bool

pkg/scheduler/backend/cache/node_tree.go1

75:5inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/scheduler/backend/cache/node_tree.go:75:5

74 if nodeName == n.Name {
75 nt.tree[zone] = append(na[:i], na[i+1:]...)
76 if len(nt.tree[zone]) == 0 {

pkg/kubeapiserver/options/authentication_test.go1

1664:41insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:1664:41

1663 Lookup: true,
1664 Issuers: []string{"http://foo.bar.com"},
1665 KeyFiles: []string{},

pkg/scheduler/metrics/resources/resources.go1

162:6max-parametersfunction has 10 parameters; maximum is 8

pkg/scheduler/metrics/resources/resources.go:162:6

161
162func recordMetricWithUnit(
163 ch chan<- metrics.Metric,

pkg/scheduler/apis/config/types_pluginargs.go1

149:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types_pluginargs.go:149:6

148// VolumeBindingArgs holds arguments used to configure the VolumeBinding plugin.
149type VolumeBindingArgs struct {
150 metav1.TypeMeta

pkg/proxy/apis/config/v1alpha1/conversion.go1

47:3modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:47:3

46 case kubeproxyconfig.ProxyModeNFTables:
47 out.NFTables.SyncPeriod = in.SyncPeriod
48 out.NFTables.MinSyncPeriod = in.MinSyncPeriod

pkg/scheduler/framework/plugins/interpodaffinity/scoring.go1

57:4modifies-value-receiverassignment modifies value receiver m

pkg/scheduler/framework/plugins/interpodaffinity/scoring.go:57:4

56 }
57 m[term.TopologyKey][tpValue] += int64(weight * multiplier)
58 }

pkg/proxy/apis/config/validation/validation_test.go1

434:41nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/validation/validation_test.go:434:41

433 newPath := field.NewPath("KubeProxyConfiguration")
434 for name, testCase := range map[string]struct {
435 mode kubeproxyconfig.ProxyMode

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

576:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:576:4

575 t.Logf("unexpected error %v", err)
576 return false, nil
577 }

pkg/registry/core/pod/strategy_test.go1

964:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/core/pod/strategy_test.go:964:2

963func (f fakeTransport) RoundTrip(*http.Request) (*http.Response, error) {
964 return nil, nil
965}

pkg/registry/autoscaling/rest/storage_autoscaling.go1

53:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/autoscaling/rest/storage_autoscaling.go:53:4

52 return genericapiserver.APIGroupInfo{}, err
53 } else if len(storageMap) > 0 {
54 apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv2.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/plugins/podgrouppodscount/podgroup_pods_count_test.go1

40:6no-initreplace init with explicit initialization

pkg/scheduler/framework/plugins/podgrouppodscount/podgroup_pods_count_test.go:40:6

39
40func init() {
41 metrics.Register()

pkg/proxy/nftables/proxier.go1

1768:2no-naked-returnreturn values must be explicit

pkg/proxy/nftables/proxier.go:1768:2

1767 }
1768 return
1769}

pkg/proxy/apis/config/scheme/scheme.go1

29:2no-package-varpackage variables introduce mutable global state

pkg/proxy/apis/config/scheme/scheme.go:29:2

28 // Scheme defines methods for serializing and deserializing API objects.
29 Scheme = runtime.NewScheme()
30 // Codecs provides methods for retrieving codecs and serializers for specific

pkg/kubeapiserver/options/authorization.go1

199:10optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authorization.go:199:10

198
199 return fs.Changed(authorizationModeFlag) ||
200 fs.Changed(authorizationWebhookConfigFileFlag) ||

pkg/proxy/apis/config/fuzzer/fuzzer.go1

17:9package-commentspackage should have a documentation comment

pkg/proxy/apis/config/fuzzer/fuzzer.go:17:9

16
17package fuzzer
18

pkg/scheduler/framework/preemption/podgrouppreemption_test.go1

1470:105possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/preemption/podgrouppreemption_test.go:1470:105

1469 if res.numPodGroupDisruptions != tt.expectedNumPodGroupDisruptions {
1470 t.Errorf("numPodGroupDisruptions mismatch. Want %d, Got %d", tt.expectedNumPodGroupDisruptions, res.numPodGroupDisruptions)
1471 }

pkg/proxy/ipvs/proxier.go1

976:14range-value-addresstaking the address of range value ingress can be misleading

pkg/proxy/ipvs/proxier.go:976:14

975 if allowFromNode {
976 entry = &utilipset.Entry{
977 IP: ingress.String(),

pkg/registry/rbac/role/policybased/storage.go1

80:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/role/policybased/storage.go:80:7

79
80func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
81 if rbacregistry.EscalationAllowed(ctx) || rbacregistry.RoleEscalationAuthorized(ctx, s.authorizer) {

pkg/registry/core/rest/storage_core.go1

346:81redefines-builtin-ididentifier max shadows a predeclared identifier

pkg/registry/core/rest/storage_core.go:346:81

345 if !utilfeature.DefaultFeatureGate.Enabled(features.MultiCIDRServiceAllocator) {
346 primaryClusterIPAllocator, err = ipallocator.New(&serviceClusterIPRange, func(max int, rangeSpec string, offset int) (allocator.Interface, error) {
347 var mem allocator.Snapshottable

pkg/proxy/conntrack/cleanup_test.go1

161:22redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/conntrack/cleanup_test.go:161:22

160 Name: ptr.To("test-tcp"),
161 Port: ptr.To(int32(testEndpointPort)),
162 Protocol: ptr.To(v1.ProtocolTCP),

pkg/proxy/ipvs/cleanup.go1

25:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/ipvs/cleanup.go:25:2

24
25 v1 "k8s.io/api/core/v1"
26 "k8s.io/klog/v2"

pkg/proxy/healthcheck/service_health.go1

66:2single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/healthcheck/service_health.go:66:2

65
66 switch serviceFamily {
67 case v1.IPv4Protocol:

pkg/registry/core/namespace/storage/storage.go1

226:6slice-preallocationpreallocate newFinalizers with capacity len(range source) before appending once per iteration

pkg/registry/core/namespace/storage/storage.go:226:6

225 if changeNeeded {
226 newFinalizers := []string{}
227 for f := range currentFinalizers {

pkg/proxy/iptables/proxier_test.go1

4098:1task-commentTODO comment should be resolved or linked to an owned work item

pkg/proxy/iptables/proxier_test.go:4098:1

4097
4098// TODO(thockin): add *more* tests for syncProxyRules() or break it down further and test the pieces.
4099

pkg/kubeapiserver/options/authentication_test.go1

1090:6test-parallelismconsider calling t.Parallel() when this test begins

pkg/kubeapiserver/options/authentication_test.go:1090:6

1089
1090func TestValidateOIDCOptions(t *testing.T) {
1091 testCases := []struct {

pkg/proxy/conntrack/filter.go1

34:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/conntrack/filter.go:34:1

33
34var _ netlink.CustomConntrackFilter = (*flowFilter)(nil)
35

pkg/proxy/winkernel/proxier_test.go1

2513:26unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/proxier_test.go:2513:26

2512 // Pre-populate the local HNS endpoint (as CNI would create it).
2513 hcnMock := (proxier.hcn).(*fakehcn.HcnMock)
2514 hcnMock.PopulateQueriedEndpoints(endpointLocal1, networkId, localIP, macAddressLocal1, prefixLen)

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go1

499:75unexported-returnexported function returns an unexported type

pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration_test.go:499:75

498// must be called after WithLimited
499func (b *plBuilder) WithQueuing(queues, handSize, queueLengthLimit int32) *plBuilder {
500 limited := b.object.Spec.Limited

pkg/proxy/conntrack/sysctls_test.go1

108:42unused-parameterparameter ctx is unused

pkg/proxy/conntrack/sysctls_test.go:108:42

107}
108func (fc *fakeConntracker) SetUDPTimeout(ctx context.Context, seconds int) error {
109 fc.called = append(fc.called, fmt.Sprintf("SetUDPTimeout(%d)", seconds))

pkg/proxy/healthcheck/service_health.go1

302:7unused-receiverreceiver fake is unused

pkg/proxy/healthcheck/service_health.go:302:7

301// SyncServices is part of ServiceHealthServer
302func (fake FakeServiceHealthServer) SyncServices(_ map[types.NamespacedName]uint16) error {
303 return nil

pkg/proxy/config/config.go1

381:36use-anyuse any instead of interface{}

pkg/proxy/config/config.go:381:36

380 },
381 UpdateFunc: func(oldObj, newObj interface{}) {
382 result.handleServiceCIDREvent(oldObj, newObj)

pkg/kubeapiserver/options/authentication.go1

909:15use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication.go:909:15

908 if configuration == nil { // sanity check, this should never happen but check just in case since we rely on it
909 return nil, fmt.Errorf("expected non-nil AuthenticationConfiguration")
910 }

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go1

1270:6use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go:1270:6

1269 victims := got[i].Victims().Pods
1270 sort.Slice(victims, func(i, j int) bool {
1271 return victims[i].Name < victims[j].Name

pkg/proxy/endpointschangetracker_test.go1

1090:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/endpointschangetracker_test.go:1090:2

1089 startTime := time.Date(2018, 01, 01, 0, 0, 0, 0, time.UTC)
1090 t_1 := startTime.Add(-time.Second)
1091 t0 := startTime.Add(time.Second)

pkg/kubeapiserver/options/authentication_test.go1

215:32add-constantstring literal "key" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:215:32

214 testSA: &ServiceAccountAuthenticationOptions{
215 KeyFiles: []string{"cert", "key"},
216 Issuers: []string{"http://foo.bar.com"},

pkg/kubeapiserver/options/authorization.go1

208:39cognitive-complexityfunction has cognitive complexity 8; maximum is 7

pkg/kubeapiserver/options/authorization.go:208:39

207// ToAuthorizationConfig convert BuiltInAuthorizationOptions to authorizer.Config
208func (o *BuiltInAuthorizationOptions) ToAuthorizationConfig(versionedInformerFactory versionedinformers.SharedInformerFactory) (*authorizer.Config, error) {
209 if o == nil {

pkg/registry/core/service/storage/transaction.go1

52:31confusing-namingname Commit differs from commit only by capitalization

pkg/registry/core/service/storage/transaction.go:52:31

51
52func (cb callbackTransaction) Commit() {
53 if cb.commit != nil {

pkg/scheduler/framework/plugins/volumebinding/binder.go1

837:132confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/plugins/volumebinding/binder.go:837:132

836
837func (b *volumeBinder) checkBoundClaims(logger klog.Logger, claims []*v1.PersistentVolumeClaim, node *v1.Node, pod *v1.Pod) (bool, bool, error) {
838 csiNode, err := b.csiNodeLister.Get(node.Name)

pkg/registry/rbac/clusterrolebinding/registry.go1

42:6constructor-interface-returnNewRegistry returns interface Registry although its concrete result is consistently *storage; return the concrete type

pkg/registry/rbac/clusterrolebinding/registry.go:42:6

41// types will panic.
42func NewRegistry(s rest.StandardStorage) Registry {
43 return &storage{s}

pkg/proxy/endpointslicecache.go1

197:34cyclomatic-complexityfunction complexity is 16; maximum is 10

pkg/proxy/endpointslicecache.go:197:34

196// addEndpoints adds an Endpoint for each unique endpoint.
197func (cache *EndpointSliceCache) addEndpoints(svcPortName *ServicePortName, portNum int, endpointSet map[string]Endpoint, endpoints []discovery.Endpoint) map[string]Endpoint {
198 if endpointSet == nil {

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

222:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.ProofOfPossession is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:222:5

221 PKIXPublicKey: ed25519PubPKIX1,
222 ProofOfPossession: ed25519Proof1,
223 UnverifiedUserAnnotations: map[string]string{"test/foo": "bar"},

pkg/proxy/healthcheck/healthcheck_test.go1

176:2discarded-error-resulterror result returned by hcs.SyncServices is discarded

pkg/proxy/healthcheck/healthcheck_test.go:176:2

175 nsn := mknsn("a", "b")
176 hcs.SyncServices(map[types.NamespacedName]uint16{nsn: 9376})
177 if len(hcs.services) != 1 {

pkg/kubeapiserver/options/authentication.go1

84:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/options/authentication.go:84:1

83
84// BuiltInAuthenticationOptions contains all build-in authentication options for API Server
85type BuiltInAuthenticationOptions struct {

pkg/proxy/conntrack/conntrack_test.go1

163:14error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/conntrack/conntrack_test.go:163:14

162 if len(left) != tc.expectedLeft {
163 t.Errorf("ListEntries() left = %d, want %d", len(left), tc.expectedLeft)
164 }

pkg/kubeapiserver/options/admission.go1

115:28exported-declaration-commentexported function or method should have a comment beginning with its name

pkg/kubeapiserver/options/admission.go:115:28

114// Kube-apiserver just call generic AdmissionOptions.ApplyTo.
115func (a *AdmissionOptions) ApplyTo(
116 c *server.Config,

pkg/proxy/nftables/helpers_test.go1

1:1file-length-limitfile has 1146 lines; maximum is 500

pkg/proxy/nftables/helpers_test.go:1:1

1//go:build linux
2

pkg/proxy/ipvs/proxier.go1

393:18flag-parameterboolean parameter wantIPv6 controls function flow

pkg/proxy/ipvs/proxier.go:393:18

392
393func filterCIDRs(wantIPv6 bool, cidrs []string) []string {
394 var filteredCIDRs []string

pkg/kubeapiserver/options/options.go1

1:1formatfile is not formatted

pkg/kubeapiserver/options/options.go:1:1

1/*
2Copyright 2017 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/kubeapiserver/options/options.go`

pkg/kubeapiserver/options/authorization_test.go1

34:6function-lengthfunction has 17 statements and 108 lines; maximum is 50 statements or 75 lines

pkg/kubeapiserver/options/authorization_test.go:34:6

33
34func TestAuthzValidate(t *testing.T) {
35 examplePolicyFile := "../../auth/authorizer/abac/example_policy_file.jsonl"

pkg/scheduler/extender.go1

249:24function-result-limitfunction returns 4 values; maximum is 3

pkg/scheduler/extender.go:249:24

248// unresolvable.
249func (h *HTTPExtender) Filter(
250 pod *v1.Pod,

pkg/proxy/ipvs/proxier.go1

1492:2import-shadowingidentifier sets shadows an imported package

pkg/proxy/ipvs/proxier.go:1492:2

1491func (proxier *Proxier) acceptIPVSTraffic() {
1492 sets := []string{kubeClusterIPSet, kubeLoadBalancerSet}
1493 for _, set := range sets {

pkg/scheduler/backend/cache/node_tree.go1

76:12inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/scheduler/backend/cache/node_tree.go:76:12

75 nt.tree[zone] = append(na[:i], na[i+1:]...)
76 if len(nt.tree[zone]) == 0 {
77 nt.removeZone(zone)

pkg/kubeapiserver/options/authentication_test.go1

1670:52insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:1670:52

1669 expectConfig: kubeauthenticator.Config{
1670 APIAudiences: authenticator.Audiences{"http://foo.bar.com"},
1671 ServiceAccountLookup: true,

pkg/scheduler/schedule_one_test.go1

4661:6max-parametersfunction has 10 parameters; maximum is 8

pkg/scheduler/schedule_one_test.go:4661:6

4660// cache: scheduler cache that might contain assumed pods.
4661func setupTestSchedulerWithOnePodOnNode(ctx context.Context, t *testing.T, client clientset.Interface, queuedPodStore *clientcache.FIFO, scache internalcache.Cache, apiDispatcher *apidispatcher.APIDispatcher,
4662 pod *v1.Pod, node *v1.Node, bindingChan chan *v1.Binding, fns ...tf.RegisterPluginFunc) (*Scheduler, chan error) {

pkg/scheduler/apis/config/types_pluginargs.go1

176:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types_pluginargs.go:176:6

175// NodeAffinityArgs holds arguments to configure the NodeAffinity plugin.
176type NodeAffinityArgs struct {
177 metav1.TypeMeta

pkg/proxy/apis/config/v1alpha1/conversion.go1

48:3modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:48:3

47 out.NFTables.SyncPeriod = in.SyncPeriod
48 out.NFTables.MinSyncPeriod = in.MinSyncPeriod
49 default:

pkg/scheduler/framework/plugins/interpodaffinity/scoring.go1

72:4modifies-value-receiverassignment modifies value receiver m

pkg/scheduler/framework/plugins/interpodaffinity/scoring.go:72:4

71 if scores == nil {
72 m[topology] = oScores
73 continue

pkg/proxy/apis/config/validation/validation_test.go1

505:41nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/validation/validation_test.go:505:41

504 newPath := field.NewPath("KubeProxyConfiguration")
505 for name, testCase := range map[string]struct {
506 mode kubeproxyconfig.ProxyMode

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

635:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:635:4

634 t.Logf("unexpected error %v", err)
635 return false, nil
636 }

pkg/registry/core/rest/storage_core_test.go1

45:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/core/rest/storage_core_test.go:45:2

44func (f fakeStorageFactory) NewConfig(groupResource schema.GroupResource, example runtime.Object) (*storagebackend.ConfigForResource, error) {
45 return nil, nil
46}

pkg/registry/autoscaling/rest/storage_autoscaling.go1

59:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/autoscaling/rest/storage_autoscaling.go:59:4

58 return genericapiserver.APIGroupInfo{}, err
59 } else if len(storageMap) > 0 {
60 apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv1.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/plugins/podtopologyspread/filtering_test.go1

68:6no-initreplace init with explicit initialization

pkg/scheduler/framework/plugins/podtopologyspread/filtering_test.go:68:6

67
68func init() {
69 metrics.Register()

pkg/proxy/topology.go1

51:3no-naked-returnreturn values must be explicit

pkg/proxy/topology.go:51:3

50 // If there are no endpoints, we have nothing to categorize
51 return
52 }

pkg/proxy/apis/config/scheme/scheme.go1

32:2no-package-varpackage variables introduce mutable global state

pkg/proxy/apis/config/scheme/scheme.go:32:2

31 // versions and content types.
32 Codecs = serializer.NewCodecFactory(Scheme, serializer.EnableStrict)
33)

pkg/kubeapiserver/options/authorization.go1

199:10optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authorization.go:199:10

198
199 return fs.Changed(authorizationModeFlag) ||
200 fs.Changed(authorizationWebhookConfigFileFlag) ||

pkg/proxy/apis/config/register.go1

17:9package-commentspackage should have a documentation comment

pkg/proxy/apis/config/register.go:17:9

16
17package config
18

pkg/scheduler/framework/preemption/podgrouppreemption_test.go1

1472:11possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/preemption/podgrouppreemption_test.go:1472:11

1471 }
1472 if res.victims.NumPDBViolations != int64(tt.expectedNumPDBViolations) {
1473 t.Errorf("NumPDBViolations mismatch. Want %d, Got %d", tt.expectedNumPDBViolations, res.victims.NumPDBViolations)

pkg/proxy/ipvs/proxier.go1

996:12range-value-addresstaking the address of range value ingress can be misleading

pkg/proxy/ipvs/proxier.go:996:12

995 // ipvs call
996 serv := &utilipvs.VirtualServer{
997 Address: ingress,

pkg/registry/rbac/role/policybased/storage.go1

105:7receiver-namingreceiver name s is inconsistent with r

pkg/registry/rbac/role/policybased/storage.go:105:7

104
105func (s *Storage) GetSingularName() string {
106 snp, ok := s.StandardStorage.(rest.SingularNameProvider)

pkg/registry/core/rest/storage_core.go1

367:72redefines-builtin-ididentifier max shadows a predeclared identifier

pkg/registry/core/rest/storage_core.go:367:72

366 if !utilfeature.DefaultFeatureGate.Enabled(features.DisableAllocatorDualWrite) {
367 bitmapAllocator, err = ipallocator.New(&serviceClusterIPRange, func(max int, rangeSpec string, offset int) (allocator.Interface, error) {
368 mem := allocator.NewAllocationMapWithOffset(max, rangeSpec, offset)

pkg/proxy/conntrack/cleanup_test.go1

166:22redundant-conversionconversion from int32 to the identical type is redundant

pkg/proxy/conntrack/cleanup_test.go:166:22

165 Name: ptr.To("test-udp"),
166 Port: ptr.To(int32(testEndpointPort)),
167 Protocol: ptr.To(v1.ProtocolUDP),

pkg/proxy/ipvs/cleanup_test.go1

28:2redundant-import-aliasimport alias is identical to the package name

pkg/proxy/ipvs/cleanup_test.go:28:2

27
28 v1 "k8s.io/api/core/v1"
29 discovery "k8s.io/api/discovery/v1"

pkg/proxy/iptables/proxier_test.go1

673:4single-case-switchswitch with one case can be replaced by an if statement

pkg/proxy/iptables/proxier_test.go:673:4

672 sort.Slice(table.Chains, func(i, j int) bool {
673 switch {
674 case table.Chains[i].Name == kubeNodePortsChain:

pkg/registry/core/pod/storage/eviction.go1

504:6slice-preallocationpreallocate pdbs with capacity len(range source) before appending once per iteration

pkg/registry/core/pod/storage/eviction.go:504:6

503
504 var pdbs []policyv1.PodDisruptionBudget
505 for _, pdb := range pdbList.Items {

pkg/proxy/ipvs/cleanup_test.go1

162:2task-commentFIXME comment should be resolved or linked to an owned work item

pkg/proxy/ipvs/cleanup_test.go:162:2

161
162 // FIXME: check ipvs and ipset state
163}

pkg/kubeapiserver/options/authentication_test.go1

1224:18test-parallelismconsider calling t.Parallel() when this subtest begins

pkg/kubeapiserver/options/authentication_test.go:1224:18

1223 for _, tt := range testCases {
1224 t.Run(tt.name, func(t *testing.T) {
1225 opts := NewBuiltInAuthenticationOptions().WithOIDC()

pkg/proxy/conntrack/sysctls.go1

43:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

pkg/proxy/conntrack/sysctls.go:43:1

42// https://www.kernel.org/doc/Documentation/networking/nf_conntrack-sysctl.txt
43type conntrackConfigurer interface {
44 // SetMax adjusts nf_conntrack_max.

pkg/proxy/winkernel/proxier_test.go1

2554:46unchecked-type-assertionuse the checked two-result form of the type assertion

pkg/proxy/winkernel/proxier_test.go:2554:46

2553 // Record the old LB IDs for both services.
2554 svc1Info := proxier.svcPortMap[svcPortName1].(*serviceInfo)
2555 svc2Info := proxier.svcPortMap[svcPortName2].(*serviceInfo)

pkg/registry/resource/resourceclaim/strategy.go1

58:97unexported-returnexported function returns an unexported type

pkg/registry/resource/resourceclaim/strategy.go:58:97

57// NewStrategy is the default logic that applies when creating and updating ResourceClaim objects.
58func NewStrategy(nsClient v1.NamespaceInterface, authorizer authorizer.UnconditionalAuthorizer) *resourceclaimStrategy {
59 return &resourceclaimStrategy{

pkg/proxy/conntrack/sysctls_test.go1

112:48unused-parameterparameter ctx is unused

pkg/proxy/conntrack/sysctls_test.go:112:48

111}
112func (fc *fakeConntracker) SetUDPStreamTimeout(ctx context.Context, seconds int) error {
113 fc.called = append(fc.called, fmt.Sprintf("SetUDPStreamTimeout(%d)", seconds))

pkg/proxy/healthcheck/service_health.go1

307:7unused-receiverreceiver fake is unused

pkg/proxy/healthcheck/service_health.go:307:7

306// SyncEndpoints is part of ServiceHealthServer
307func (fake FakeServiceHealthServer) SyncEndpoints(_ map[types.NamespacedName]int) error {
308 return nil

pkg/proxy/config/config.go1

384:25use-anyuse any instead of interface{}

pkg/proxy/config/config.go:384:25

383 },
384 DeleteFunc: func(obj interface{}) {
385 result.handleServiceCIDREvent(obj, nil)

pkg/kubeapiserver/options/authentication_test.go1

1691:17use-errors-newreplace fmt.Errorf with errors.New for a static message

pkg/kubeapiserver/options/authentication_test.go:1691:17

1690 },
1691 expectedErr: fmt.Errorf("cannot set mutually exclusive flags `--service-account-key-file` and `--service-account-signing-endpoint` at the same time"),
1692 },

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go1

1274:5use-slices-sortuse slices.Sort or slices.SortFunc when possible

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go:1274:5

1273 }
1274 sort.Slice(got, func(i, j int) bool {
1275 return got[i].Name() < got[j].Name()

pkg/proxy/nftables/proxier.go1

406:2var-namingidentifier should use MixedCaps rather than underscores

pkg/proxy/nftables/proxier.go:406:2

405 ipX := "ip"
406 ipvX_addr := "ipv4_addr" //nolint:staticcheck // var name intentionally resembles value
407 noLocalhost := "ip daddr != 127.0.0.0/8"

pkg/kubeapiserver/options/authentication_test.go1

239:34add-constantstring literal "configfile" appears more than twice; define a constant

pkg/kubeapiserver/options/authentication_test.go:239:34

238 name: "test when authentication config file and oidc-* flags are set",
239 testAuthenticationConfigFile: "configfile",
240 testOIDC: &OIDCAuthenticationOptions{

pkg/kubeapiserver/options/authorization_test.go1

34:6cognitive-complexityfunction has cognitive complexity 10; maximum is 7

pkg/kubeapiserver/options/authorization_test.go:34:6

33
34func TestAuthzValidate(t *testing.T) {
35 examplePolicyFile := "../../auth/authorizer/abac/example_policy_file.jsonl"

pkg/registry/core/service/storage/transaction.go1

58:31confusing-namingname Revert differs from revert only by capitalization

pkg/registry/core/service/storage/transaction.go:58:31

57
58func (cb callbackTransaction) Revert() {
59 if cb.revert != nil {

pkg/scheduler/framework/preemption/preemption_test.go1

81:80confusing-resultsadjacent unnamed results of the same type should be named

pkg/scheduler/framework/preemption/preemption_test.go:81:80

80
81func (pl *FakePostFilterPlugin) GetOffsetAndNumCandidates(nodes int32) (int32, int32) {
82 return 0, nodes

pkg/registry/rbac/role/registry.go1

42:6constructor-interface-returnNewRegistry returns interface Registry although its concrete result is consistently *storage; return the concrete type

pkg/registry/rbac/role/registry.go:42:6

41// types will panic.
42func NewRegistry(s rest.StandardStorage) Registry {
43 return &storage{s}

pkg/proxy/healthcheck/healthcheck_test.go1

146:6cyclomatic-complexityfunction complexity is 41; maximum is 10

pkg/proxy/healthcheck/healthcheck_test.go:146:6

145
146func TestServer(t *testing.T) {
147 listener := newFakeListener()

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go1

271:5deprecated-api-usagek8s.io/kubernetes/pkg/apis/certificates.PKIXPublicKey is deprecated: This field is replaced by StubPKCS10Request. If StubPKCS10Request is set, this field must be empty. Signer implementations should extract the public key from the StubPKCS10Request field.

pkg/registry/certificates/podcertificaterequest/storage/storage_test.go:271:5

270 MaxExpirationSeconds: ptr.To[int32](86400),
271 PKIXPublicKey: ed25519PubPKIX1,
272 ProofOfPossession: ed25519Proof1,

pkg/proxy/healthcheck/healthcheck_test.go1

193:2discarded-error-resulterror result returned by hcs.SyncEndpoints is discarded

pkg/proxy/healthcheck/healthcheck_test.go:193:2

192 // sync an endpoint
193 hcs.SyncEndpoints(map[types.NamespacedName]int{nsn: 18})
194 if len(hcs.services) != 1 {

pkg/kubeapiserver/options/authentication.go1

102:1doc-comment-perioddocumentation comment should end with punctuation

pkg/kubeapiserver/options/authentication.go:102:1

101
102// AnonymousAuthenticationOptions contains anonymous authentication options for API Server
103type AnonymousAuthenticationOptions struct {

pkg/proxy/conntrack/filter_test.go1

85:14error-stringserror string should not be capitalized or end with punctuation

pkg/proxy/conntrack/filter_test.go:85:14

84 if match != tc.expectedMatch {
85 t.Errorf("MatchConntrackFlow() = %v, want %v", match, tc.expectedMatch)
86 }

pkg/kubeapiserver/options/authentication.go1

82:5exported-declaration-commentexported declaration should have a comment beginning with its name

pkg/kubeapiserver/options/authentication.go:82:5

81// Exported as a variable so that it can be overridden in integration tests.
82var UpdateAuthenticationConfigTimeout = time.Minute
83

pkg/proxy/nftables/proxier.go1

1:1file-length-limitfile has 1840 lines; maximum is 500

pkg/proxy/nftables/proxier.go:1:1

1//go:build linux
2

pkg/proxy/ipvs/proxier.go1

568:40flag-parameterboolean parameter value controls function flow

pkg/proxy/ipvs/proxier.go:568:40

567
568func (proxier *Proxier) setInitialized(value bool) {
569 var initialized int32

pkg/proxy/apis/config/fuzzer/fuzzer.go1

1:1formatfile is not formatted

pkg/proxy/apis/config/fuzzer/fuzzer.go:1:1

1/*
2Copyright 2018 The Kubernetes Authors.
  • Fix (safe): run `strider fmt pkg/proxy/apis/config/fuzzer/fuzzer.go`

pkg/proxy/apis/config/v1alpha1/defaults.go1

39:6function-lengthfunction has 49 statements and 102 lines; maximum is 50 statements or 75 lines

pkg/proxy/apis/config/v1alpha1/defaults.go:39:6

38
39func SetDefaults_KubeProxyConfiguration(obj *kubeproxyconfigv1alpha1.KubeProxyConfiguration) {
40

pkg/scheduler/framework/plugins/volumebinding/binder.go1

873:24function-result-limitfunction returns 4 values; maximum is 3

pkg/scheduler/framework/plugins/volumebinding/binder.go:873:24

872// and return unbound claims for further provision.
873func (b *volumeBinder) findMatchingVolumes(logger klog.Logger, pod *v1.Pod, claimsToBind []*v1.PersistentVolumeClaim, unboundVolumesDelayBinding map[string][]*v1.PersistentVolume, node *v1.Node) (foundMatches bool, bindings []*BindingInfo, unboundClaims []*v1.PersistentVolumeClaim, err error) {
874 // Sort all the claims by increasing size request to get the smallest fits

pkg/proxy/nftables/proxier.go1

165:2import-shadowingidentifier conntrack shadows an imported package

pkg/proxy/nftables/proxier.go:165:2

164 masqueradeRule string
165 conntrack conntrack.Interface
166 localDetector proxyutil.LocalTrafficDetector

pkg/scheduler/backend/cache/snapshot.go1

295:4inefficient-map-lookupreuse the map value obtained by the comma-ok lookup

pkg/scheduler/backend/cache/snapshot.go:295:4

294 if _, ok := nodeNameToInfo[nodeName]; !ok {
295 nodeNameToInfo[nodeName] = framework.NewNodeInfo()
296 }

pkg/kubeapiserver/options/authentication_test.go1

1672:37insecure-url-schemeURL uses insecure http scheme

pkg/kubeapiserver/options/authentication_test.go:1672:37

1671 ServiceAccountLookup: true,
1672 ServiceAccountIssuers: []string{"http://foo.bar.com"},
1673 },

pkg/scheduler/schedule_one_test.go1

4692:6max-parametersfunction has 9 parameters; maximum is 8

pkg/scheduler/schedule_one_test.go:4692:6

4691// scache: scheduler cache that might contain assumed pods.
4692func setupTestScheduler(ctx context.Context, t *testing.T, client clientset.Interface, queuedPodStore *clientcache.FIFO, cache internalcache.Cache, apiDispatcher *apidispatcher.APIDispatcher,
4693 informerFactory informers.SharedInformerFactory, broadcaster events.EventBroadcaster, fns ...tf.RegisterPluginFunc) (*Scheduler, chan error) {

pkg/scheduler/apis/config/types_pluginargs.go1

202:6max-public-structsfile declares more than 5 exported structs

pkg/scheduler/apis/config/types_pluginargs.go:202:6

201// ScoringStrategy define ScoringStrategyType for node resource plugin
202type ScoringStrategy struct {
203 // Type selects which strategy to run.

pkg/proxy/apis/config/v1alpha1/conversion.go1

50:3modifies-parameterassignment modifies parameter out

pkg/proxy/apis/config/v1alpha1/conversion.go:50:3

49 default:
50 out.IPTables.SyncPeriod = in.SyncPeriod
51 out.IPTables.MinSyncPeriod = in.MinSyncPeriod

pkg/scheduler/framework/plugins/volumebinding/binder.go1

60:54modifies-value-receiverassignment modifies value receiver reasons

pkg/scheduler/framework/plugins/volumebinding/binder.go:60:54

59func (reasons ConflictReasons) Less(i, j int) bool { return reasons[i] < reasons[j] }
60func (reasons ConflictReasons) Swap(i, j int) { reasons[i], reasons[j] = reasons[j], reasons[i] }
61

pkg/proxy/apis/config/validation/validation_test.go1

541:41nested-structsmove nested anonymous struct types to named declarations

pkg/proxy/apis/config/validation/validation_test.go:541:41

540 newPath := field.NewPath("KubeProxyConfiguration")
541 for name, testCase := range map[string]struct {
542 ccc componentbaseconfig.ClientConnectionConfiguration

pkg/registry/core/service/ipallocator/cidrallocator_test.go1

698:4nil-error-returnthis branch proves an error is non-nil but returns nil in an error result

pkg/registry/core/service/ipallocator/cidrallocator_test.go:698:4

697 if err != nil {
698 return false, nil
699 }

pkg/registry/rbac/clusterrole/policybased/storage_test.go1

185:2nil-value-with-nil-errornil payload is returned with a nil error; return a meaningful value or a descriptive error

pkg/registry/rbac/clusterrole/policybased/storage_test.go:185:2

184 f.created++
185 return nil, nil
186}

pkg/registry/batch/rest/storage_batch.go1

40:4no-else-after-returnremove else and unindent its body after the return

pkg/registry/batch/rest/storage_batch.go:40:4

39 return genericapiserver.APIGroupInfo{}, err
40 } else if len(storageMap) > 0 {
41 apiGroupInfo.VersionedResourcesStorageMap[batchapiv1.SchemeGroupVersion.Version] = storageMap

pkg/scheduler/framework/preemption/preemption_test.go1

68:6no-initreplace init with explicit initialization

pkg/scheduler/framework/preemption/preemption_test.go:68:6

67
68func init() {
69 metrics.Register()

pkg/proxy/topology.go1

93:3no-naked-returnreturn values must be explicit

pkg/proxy/topology.go:93:3

92 allReachableEndpoints = clusterEndpoints
93 return
94 }

pkg/proxy/apis/config/v1alpha1/register.go1

28:5no-package-varpackage variables introduce mutable global state

pkg/proxy/apis/config/v1alpha1/register.go:28:5

27// SchemeGroupVersion is group version used to register these objects
28var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
29

pkg/kubeapiserver/options/authorization_test.go1

128:7optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

pkg/kubeapiserver/options/authorization_test.go:128:7

127 errs := options.Validate()
128 if len(errs) > 0 && !testcase.expectErr {
129 t.Errorf("got unexpected err %v", errs)

pkg/proxy/apis/config/scheme/scheme.go1

17:9package-commentspackage should have a documentation comment

pkg/proxy/apis/config/scheme/scheme.go:17:9

16
17package scheme
18

pkg/scheduler/framework/preemption/podgrouppreemption_test.go1

1473:93possible-nil-dereferencepointer is dereferenced on a path where its nil check does not prove it is non-nil

pkg/scheduler/framework/preemption/podgrouppreemption_test.go:1473:93

1472 if res.victims.NumPDBViolations != int64(tt.expectedNumPDBViolations) {
1473 t.Errorf("NumPDBViolations mismatch. Want %d, Got %d", tt.expectedNumPDBViolations, res.victims.NumPDBViolations)
1474 }