-
Notifications
You must be signed in to change notification settings - Fork 27
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
scopelint: Fix improper range loop var reference #14
scopelint: Fix improper range loop var reference #14
Conversation
@dasrick I explicitly set you as a reviewer, but touched no other settings on this PR (e.g., adding labels) because we haven't yet discussed the intended scope of my involvement with this project (i.e., I did not want to make any assumptions). |
a29032e
to
7550a17
Compare
I remembered that Travis CI isn't running golangci-lint as intended (#13), so I ran it locally via |
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.
Looks better than before and the linter is fine with it.
7550a17
to
605953a
Compare
Error from `scopelint` linter: "Using a reference for the variable on range scope `img`" Fix: Use index from range loop to *reach into* the slice argument to retrieve the address of those values instead of using the range loop variable, which likely would have been a subtle source of bugs later on. refs #6, #11, #12
605953a
to
83cf781
Compare
Thanks for looking over this. I rebased yet again when a local golangci-lint run complained about unnecessary leading whitespace. While I personally like leading/trailing whitespace, I understand that it can be frowned upon. Once you've approved a PR like this one, do you want me to go ahead and merge it or leave for you to do so? |
If you are the one who created the PR and me the one who approved it, then you can merge it ... (since you have the access right to do so) ... |
Acknowledged.
Sure. I just didn't want to make any assumptions, abuse granted access/trust, etc without talking to you about it first. Thanks for clarifying! |
Summary: - Move linter choices from Makefile to separate include file - Add scopelint linter to help catch variable use outside of intended scope References: - #42 - #44 - atc0005/todo#4 - dasrick/go-teams-notify#14
Problem
Error from
scopelint
linter:"Using a reference for the variable on range scope
img
"Resolution
Use index from range loop to reach into the slice argument to retrieve the address of those values instead of using the range loop variable, which likely would have been a subtle source of bugs later on.
References