-
Notifications
You must be signed in to change notification settings - Fork 2.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 'nilness' to golangci #14066
Add 'nilness' to golangci #14066
Conversation
nilness reports: # github.com/cilium/cilium/pkg/k8s/version pkg/k8s/version/version.go:278:9: impossible condition: nil != nil Fix it by reusing the outer err variable. CC: Deepesh Pathak <deepshpathak@gmail.com> Fixes: fb101df ("k8s: add coordinationv1 capability check to k8s version package") Signed-off-by: Joe Stringer <joe@cilium.io>
nilness complains that the local secret error is hidden: pkg/crypto/certificatemanager/certificate_manager.go:81:33: impossible condition: nil != nil Fix it by unhiding the outer ioErr variable. CC: Jarno Rajahalme <jarno@covalent.io> Fixes: cabf83c ("crypto: Add local GetSecrets().") Signed-off-by: Joe Stringer <joe@cilium.io>
Suggested-by: Tam Mach <sayboras@yahoo.com> Signed-off-by: Joe Stringer <joe@cilium.io>
371e310
to
a406d1f
Compare
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.
Nice. I noticed in the fix commits, there's a CC
to the original author. Is that some new fancy way in GH to notify the original author of these commits?
@christarazi actually it's part of my old git "fixes" formatting scripts: https://github.com/joestringer/config/blob/1c050f3807e03cb8ba283c90b05416767f493576/.gitconfig#L8 |
Reassigned since it's probably more important to get the original authors to take a look both since they'll know that code and as a way to point out this pattern of bug to reduce recurrance of such issues. |
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.
LGTM 💯
nit: Minor change in github PR title to reflect lastest approach will be great, commit messages look great 👍
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.
LGTM, Thanks 🚀
test-me-please |
GKE only issue, but seems unlikely that it's any way connected to the changes in this PR: https://jenkins.cilium.io/job/Cilium-PR-K8s-GKE/3342/execution/node/115/log/
|
No need to backport to 1.9, all future patches should go through master and therefore have these checks applied at the time of submission. |
I also received out-of-band confirmation from @jrajahalme that these patches do not need backport to v1.9 as the outer code already handles such error conditions. |
Nilness checks for common programming errors like nil pointer dereference or degenerate nil pointer comparisons. It can find bugs, add it to the golangci target.
https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness
Add it to the CI, and fix up the couple of legitimate failures it complains about in the codebase.
Technically the two identified errors are bugs, but they do not appear to be at all severe so I see no strong motivation to backport this PR to v1.9.