-
Notifications
You must be signed in to change notification settings - Fork 604
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
Apply gosec and unparam to the codebase #4102
Apply gosec and unparam to the codebase #4102
Conversation
The following is the coverage report on the affected files.
|
@markusthoemmes: The following test failed, say
Full PR test history. Your PR dashboard. 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. |
for _, ref := range cleanups { | ||
for i := range cleanups { | ||
ref := cleanups[i] |
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.
Do you know which linter does this? I am curious why this is better
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's gosec
, see https://github.com/golang/go/wiki/CommonMistakes#using-reference-to-loop-iterator-variable.
It's not "better" per se, but the reference taken here might become invalid shortly, hence it ain't a good idea.
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.
That is to say: This isn't necessary in many many cases, using the range clause is fine for most cases actually. Only if you're explicitly taking a reference to the iterator variable are you potentially going to have a bad time.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: markusthoemmes, vaikas The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Proposed Changes
We've added these to the serving codebase as means to point out potential simplifications (see for example the ability to drop some error returns in the diff) and to point out potential security concerns to make us think and at least document why we've chosen to ignore them.