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: add 'unused' analyses from staticcheck #36602

Open
stamblerre opened this issue Jan 16, 2020 · 5 comments
Open

x/tools/gopls: add 'unused' analyses from staticcheck #36602

stamblerre opened this issue Jan 16, 2020 · 5 comments
Assignees
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@stamblerre
Copy link
Contributor

We don't have https://pkg.go.dev/honnef.co/go/tools/unused?tab=doc analyses in gopls because they require whole program evaluation (due to test variants). We should investigate how we can add these analyses.

@gopherbot gopherbot added this to the Unreleased milestone Jan 16, 2020
@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 Jan 16, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls unplanned Jan 16, 2020
@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 16, 2020
@stamblerre stamblerre changed the title x/tools/gopls: add unused analyses from staticcheck x/tools/gopls: add 'unused' analyses from staticcheck Jan 29, 2020
@stamblerre stamblerre added FeatureRequest and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 29, 2020
@stamblerre stamblerre modified the milestones: gopls unplanned, Unreleased Jan 29, 2020
@stamblerre
Copy link
Contributor Author

/cc @ridersofrohan

@gopherbot
Copy link

Change https://golang.org/cl/222817 mentions this issue: internal/lsp/analysis: add pass for unused parameters

@ridersofrohan
Copy link

https://golang.org/cl/222817 provides an opt in analyzer to detect potentially unused parameters.

It still needs some work, specifically:

  • Add better handling for methods, if we enable methods, we will get false positives if a struct is potentially implementing an interface.
  • Add suggested fixes to automatically remove the unused parameter.
    • We could replace the unused parameter with "_". To ensure that the function prototype still matches.
    • Then later we could remove the unused parameter from the function declaration and potentially even remove the argument from every use of this function

gopherbot pushed a commit to golang/tools that referenced this issue Mar 26, 2020
This change adds a pass that checks for unused parameters inside of a function. It is disabled by default.

Updates golang/go#36602

Change-Id: I9e8de3368f16f27e7816ec4ddb16935e1a05584e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222817
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@ridersofrohan ridersofrohan removed their assignment Apr 1, 2020
@stamblerre stamblerre removed this from the Unreleased milestone Jul 23, 2020
@stamblerre stamblerre added this to the gopls/unplanned milestone Oct 21, 2020
@gopherbot
Copy link

Change https://golang.org/cl/374254 mentions this issue: internal/lsp: add suggested fix for unusedparams analysis

gopherbot pushed a commit to golang/tools that referenced this issue Jan 14, 2022
Suggest replacing the unused function parameter with _.

Updates golang/go#36602

Change-Id: I53738e65907b8a4b4857dd8954f1477a043cf442
Reviewed-on: https://go-review.googlesource.com/c/tools/+/374254
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@adonovan
Copy link
Member

adonovan commented Jan 4, 2024

Addressing the initial note of this issue:

@adonovan adonovan self-assigned this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. 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