Skip to content
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: provide a suggested fix for unused variables #48975

Closed
findleyr opened this issue Oct 14, 2021 · 7 comments
Closed

x/tools/gopls: provide a suggested fix for unused variables #48975

findleyr opened this issue Oct 14, 2021 · 7 comments
Assignees
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

As pointed out in #48938, gopls doesn't currently tag unused variables as 'unnecessary', because we compute the 'unnecessary' tag by looking for suggested fixes that are pure deletions. We could change the way we compute the 'unnecessary' tag, but it is approximately the same amount of work to provide a suggested fix.

This is a good issue for an external contributor, as it just involves writing and hooking up an analyzer.

@findleyr findleyr added this to the gopls/unplanned milestone Oct 14, 2021
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 14, 2021
@rentziass
Copy link
Contributor

I can pick this one up, I've just done something very similar with undeclared or I can help someone else get involved?

@findleyr
Copy link
Contributor Author

CC @stamblerre

Please feel free to pick this one up. I think it should be as simple as finding the enclosing spec/decl and suggesting to delete it (though you'll have to be a bit careful about declarations with more than one spec).

@Naidile-P-N
Copy link

@rentziass I would like to contribute if it's still open

@rentziass
Copy link
Contributor

@Naidile-P-N I have something sort of ready, I was planning on finishing it this coming weekend :)

@Naidile-P-N
Copy link

@rentziass Oh cool :)

@gopherbot
Copy link

Change https://go.dev/cl/394934 mentions this issue: internal/lsp/analysis/unusedvariable: add analyzer

@findleyr
Copy link
Contributor Author

Per #54373, I think the edits produced by this analyzer need a bit more work. We'll hold off on promoting this new feature until v0.10.0 :)

@golang golang locked and limited conversation to collaborators Aug 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants