-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
Add staticcheck to verify-golangci #103723
Conversation
Welcome @hlee95! |
Hi @hlee95. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/assign nikhita |
/ok-to-test |
Yup I cherry-picked those.
I copied over the |
/retest |
unrelated to this PR I think but https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/103723/pull-kubernetes-verify/1458620020010520576 does not capture useful results in the junit, only the go mod downloads (which ... are honestly noise ...), I think the golangci-lint errors are not winding up in stdout instead of stderr, so to find them you have to expand the whole build log and read through it. we should fix that |
it's a bit ironic 🙃
|
.golangci.yaml
Outdated
"-ST1*", # Mostly stylistic, redundant w/ golint | ||
"-SA5011" # Possible nil pointer dereference | ||
] | ||
ignore_pattern: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a thing? I don't see it in https://golangci-lint.run/usage/configuration/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is indeed not a thing, I will remove it.
@aojea comments fixed in thockin@395bcb8 |
/triage accepted |
I found another bug in script - testing fix now. Basically errexit terminates if any of the runs fails, and doesn't run the rest. |
/remove priority-backlog Once this is in we have to spend some time getting this right, is easier to prevent than to find needless in haystacks |
why the linter doesn't catch these "capture variable on loop" things ? |
Code freeze looming - anything we can do to help make this work? |
can we justify to get this during the test-freeze period? I think is legit |
@hlee95: PR needs rebase. 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. |
trying to get this to the finish line #106448 |
Make verify-golangci-lint.sh work across modules and take an optional argument for a package.
@hlee95: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
#106448 supercedes. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #103721
Special notes for your reviewer:
There were a lot of failures for SA5011 "possible nil pointer dereference". The original issue showed 3 occurrences, but after I fixed those with
//nolint:staticcheck
, I found that more showed up the next time I ran the lint check. All of the occurrences of this failure happened on something of the following form:The linter says that:
I read here that the linter is unable to detect that our
framework.Failf()
function results in a panic further down the call chain, which causes the linter to flag all of these cases as a violation of SA5011. The proposed solution from that link is to add apanic("unreachable")
toframework.Failf()
so that the linter will understand that a panic occurs, so I did that and it fixed all of the errors except for two. Those two usedSkipf
instead ofFailf
, so I added thepanic("unreachable")
toSkipf
as well. The other option I thought of was to add-e SA5011
in hack/verify-golangci-lint.sh but that seemed less ideal because it could hide real errors.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: