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 · 3 comments
Open

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

stamblerre opened this issue Jan 16, 2020 · 3 comments

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jan 16, 2020

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
@stamblerre stamblerre modified the milestones: Unreleased, gopls unplanned 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 modified the milestones: gopls unplanned, Unreleased Jan 29, 2020
@stamblerre
Copy link
Contributor Author

@stamblerre stamblerre commented Mar 12, 2020

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 25, 2020

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

@ridersofrohan
Copy link

@ridersofrohan ridersofrohan commented Mar 25, 2020

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.