Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop hack/verify-staticcheck.sh in favor of enablingstaticcheck plugin in hack/verify-golangci-lint.sh #103721

Closed
dims opened this issue Jul 15, 2021 · 9 comments · Fixed by #106448
Assignees
Labels
area/code-organization Issues or PRs related to kubernetes code organization kind/bug Categorizes issue or PR as related to a bug. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/testing Categorizes an issue or PR as relevant to SIG Testing. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@dims
Copy link
Member

dims commented Jul 15, 2021

Step 1: Enable staticcheck plugin in verify-golangci-lint.sh

$ git diff hack
diff --git a/hack/verify-golangci-lint.sh b/hack/verify-golangci-lint.sh
index 1e0bc1192ed..237352b678f 100755
--- a/hack/verify-golangci-lint.sh
+++ b/hack/verify-golangci-lint.sh
@@ -50,4 +50,5 @@ golangci-lint run \
   -E deadcode \
   -E unused \
   -E varcheck \
-  -E ineffassign
+  -E ineffassign \
+  -E staticcheck

Step 2: run hack/verify-golangci-lint.sh and see the failures. As of opening this bug the failures are as follows:

[19353:19352 - 0:1910] 01:23:07 [dims@bigbox:/dev/pts/0 +1] ~/go/src/k8s.io/kubernetes
$ hack/verify-golangci-lint.sh
installing golangci-lint
running golangci-lint
pkg/volume/util/fsquota/quota_linux.go:307:50: SA4009: argument poduid is overwritten before first use (staticcheck)
func AssignQuota(m mount.Interface, path string, poduid types.UID, bytes *resource.Quantity) error {
                                                 ^
pkg/volume/util/fsquota/quota_linux.go:322:2: SA4009(related information): assignment to poduid (staticcheck)
	poduid = types.UID(uuid.NewUUID())
	^
cmd/kube-proxy/app/server.go:616:30: SA1019: legacyregistry.Handler is deprecated: Please note the issues described in the doc comment of InstrumentHandler. You might want to consider using promhttp.Handler instead. (staticcheck)
	proxyMux.Handle("/metrics", legacyregistry.Handler())
	                            ^
cmd/kube-scheduler/app/config/config.go:50:19: SA1019: events.EventBroadcasterAdapter is deprecated: This interface will be removed once migration is completed. (staticcheck)
	EventBroadcaster events.EventBroadcasterAdapter
	                 ^
pkg/kubelet/dockershim/docker_container.go:184:42: SA1019: config.GetLinux().GetSecurityContext().GetSeccompProfilePath is deprecated: Do not use. (staticcheck)
	securityOpts, err := ds.getSecurityOpts(config.GetLinux().GetSecurityContext().GetSeccompProfilePath(), securityOptSeparator)
	                                        ^
pkg/kubelet/kuberuntime/instrumented_services_test.go:44:25: SA1019: legacyregistry.Handler is deprecated: Please note the issues described in the doc comment of InstrumentHandler. You might want to consider using promhttp.Handler instead. (staticcheck)
	mux.Handle("/metrics", legacyregistry.Handler())
	                       ^
pkg/kubelet/server/server.go:352:36: SA1019: legacyregistry.Handler is deprecated: Please note the issues described in the doc comment of InstrumentHandler. You might want to consider using promhttp.Handler instead. (staticcheck)
	s.restfulCont.Handle(metricsPath, legacyregistry.Handler())
	                                  ^
pkg/registry/core/namespace/storage/storage.go:257:5: SA1019: options.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 (staticcheck)
	if options.OrphanDependents != nil {
	   ^
pkg/registry/core/namespace/storage/storage.go:259:11: SA1019: options.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 (staticcheck)
		return *options.OrphanDependents
		        ^
pkg/registry/core/namespace/storage/storage.go:269:5: SA1019: options.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 (staticcheck)
	if options.OrphanDependents != nil {
	   ^
test/integration/scheduler_perf/scheduler_perf_legacy_test.go:443:3: SA3001: should not assign to b.N (staticcheck)
		b.N = minPods
		^
pkg/kubelet/status/status_manager.go:160:16: SA1015: using time.Tick leaks the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (staticcheck)
	syncTicker := time.Tick(syncPeriod)
	              ^
pkg/kubelet/cm/cpuset/cpuset.go:61:2: SA4005: ineffective assignment to field Builder.done (staticcheck)
	b.done = true
	^
pkg/util/flag/flags.go:53:3: SA4005: ineffective assignment to field IPVar.Val (staticcheck)
		v.Val = nil
		^
pkg/util/flag/flags.go:88:3: SA4005: ineffective assignment to field IPPortVar.Val (staticcheck)
		v.Val = nil
		^
test/e2e/apimachinery/garbage_collector.go:70:19: SA4025: the integer division '8 / 10' results in zero (staticcheck)
	availablePods *= 8 / 10
	                 ^
test/e2e/framework/autoscaling/autoscaling_utils.go:326:36: SA5011: possible nil pointer dereference (staticcheck)
		return int(replicationController.Status.ReadyReplicas)
		                                 ^
test/e2e/framework/autoscaling/autoscaling_utils.go:323:6: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
		if replicationController == nil {
		   ^
test/e2e/framework/autoscaling/autoscaling_utils.go:333:25: SA5011: possible nil pointer dereference (staticcheck)
		return int(deployment.Status.ReadyReplicas)
		                      ^
test/e2e/framework/autoscaling/autoscaling_utils.go:330:6: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
		if deployment == nil {
		   ^
test/e2e/framework/autoscaling/autoscaling_utils.go:340:17: SA5011: possible nil pointer dereference (staticcheck)
		return int(rs.Status.ReadyReplicas)
		              ^
test/e2e/framework/autoscaling/autoscaling_utils.go:337:6: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
		if rs == nil {
		   ^

Step 3: fix each instance, either by making a minimal code change or adding a //nolint:staticcheck (for example to ignore the deprecation warnings, see https://golangci-lint.run/usage/false-positives/)

Step 4: remove hack/verify-staticcheck.sh and cleanup hack/tools/go.mod to remove references to honnef.co/go/tools/cmd/staticcheck which is used in that script

@dims dims added the kind/bug Categorizes issue or PR as related to a bug. label Jul 15, 2021
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jul 15, 2021
@dims
Copy link
Member Author

dims commented Jul 15, 2021

/sig architecture
/sig testing
/are code-organization

@k8s-ci-robot k8s-ci-robot added sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 15, 2021
@nikhita
Copy link
Member

nikhita commented Jul 15, 2021

/assign @hlee95

@k8s-ci-robot
Copy link
Contributor

@nikhita: GitHub didn't allow me to assign the following users: hlee95.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @hlee95

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hlee95
Copy link
Contributor

hlee95 commented Jul 15, 2021

/assign

@mcbenjemaa
Copy link
Member

OSD very fast to pickup 🥇

@nikhita
Copy link
Member

nikhita commented Jul 15, 2021

/are code-organization

/area code-organization

@k8s-ci-robot k8s-ci-robot added the area/code-organization Issues or PRs related to kubernetes code organization label Jul 15, 2021
@spiffxp spiffxp added this to To Triage in sig-testing issues Jul 27, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 13, 2021
@BenTheElder
Copy link
Member

/remove-lifecycle stale
(since there's been a recent dupe)

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 13, 2021
@BenTheElder
Copy link
Member

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 13, 2021
@BenTheElder BenTheElder moved this from To Triage to Backlog in sig-testing issues Oct 13, 2021
sig-testing issues automation moved this from Backlog to Done Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code-organization Issues or PRs related to kubernetes code organization kind/bug Categorizes issue or PR as related to a bug. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/testing Categorizes an issue or PR as relevant to SIG Testing. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging a pull request may close this issue.

7 participants