-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use typesinfo to compare packages #6
Conversation
This avoids a false positive in shadow.go (see #5), and enables detecting dot-imported and indirect reassignments in dotimport.go. The indirect reassignment is flagged when taking the address, so may require further filtering to avoid annoying false positives.
This ended up being a larger change to the original implementation than I'm comfortable requesting. So please feel free to take either the whole, or any pieces of it that you like. Main changes:
|
Thanks @MichaelUrman! I think this means the linter will move from the syntax phase to types phase of golanglint which is fine. I'm not sure if |
I'm not familiar enough with the phases to comment, but I do agree that this approach requires types. I don't know if the inspector dependency changes anything related to that; I saw it a performance tradeoff that's easy to revert. As for An alternate implementation might leverage SSA. Stores to addresses that come only from globals should be safe to report. Ones that potentially come from elsewhere (including function params) would be easy to skip. So at the cost of certain kinds of false negatives, false positives should be preventable, and the reports would be on the assignment. But introducing SSA processing is a much larger change. Perhaps it would be better to reject Feel free to choose a direction and ask me to update the PR accordingly. (No guarantees on my turnaround.) Or to update this code yourself or take ideas from it and merge your own version separately from this PR. I won't be offended. (I can't believe I committed with |
Thanks @MichaelUrman for the context and discussion. Agree that it sounds like it's good to keep the change to fixing the issue with shadowing for now and explore address-taking in the future. I have gone ahead and pushed the change to this PR |
Thanks again @MichaelUrman - will try to get this released and a PR to update golangci within the next few days |
This avoids a false positive in shadow.go, and enables detecting dot-imported.
Fixes #5