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
x/tools/gopls: add the unusedwrite analysis #44461
Comments
We'd be happy to accept a CL--if you think it should be off by default, we can start with that first, and then enable it later on? |
Ah, looks like it uses SSA, so let's keep it off by default to start. |
Change https://golang.org/cl/295172 mentions this issue: |
Thanks for reviewing! |
SSA is now enabled by default (for nilness), so the marginal cost of enabling unusedwrite is very small. I just ran a very quick experiment and found that 10 out of 10 findings I randomly sampled in kubernetes were genuine opportunities for simplification. So let's do a proper evaluation and perhaps enable it in gopls. |
I should run a job over the Module Mirror corpus to get results that we can share, but in the meantime Googlers can inspect a list of findings of this analyzer on Google source code at go/unusedwrite-diagnostics-b1c6ea0fd8b46c. The false positive rate is zero in my manual sampling so far. I think this might be a good feature for gopls. |
They're not bugs, but they do indicate that a field of a struct is assigned but never used, which is a sign that the code is building a bigger data structure than it actually needs. |
CL 287034 added the new
unusedwrite
analysis pass. I think it would be nice to have ingopls
.I'm not sure if it should be among the default analysers, but either way, if there are no objections to this, I am ready to send a CL.
The text was updated successfully, but these errors were encountered: