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: ui.diagnostic.analyses -> shadow should allow exclude-rules, eg for err #67440

Closed
Roemer opened this issue May 14, 2024 · 2 comments
Labels
gopls/analysis Issues related to running analysis in gopls gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@Roemer
Copy link

Roemer commented May 14, 2024

Is your feature request related to a problem? Please describe.
Showing shadowed variables can help to prevent some bugs but in most go code, the variable err is quite often shadowed which is ok. Therefore we see a lot of shadowed warnings which are not relevant and it is harder to see the relevant ones.

Describe the solution you'd like
When shadow is enabled, it should also be possible to add some kind of ignores like either directly exclude variable names or at least messages like govet with exclude-rules.

Describe alternatives you've considered
I couldn't find an alternative except for keeping shadow disabled.

@hyangah hyangah changed the title ui.diagnostic.analyses -> shadow should allow exclude-rules, eg for err x/tools/gopls: ui.diagnostic.analyses -> shadow should allow exclude-rules, eg for err May 16, 2024
@hyangah
Copy link
Contributor

hyangah commented May 16, 2024

Transferring to the gopls issue tracker.
This is similar to the proposal #61574 (x/tools/go/analysis/passes/shadow).
And, there is another discussion about err handling. #40113

However, there are more to discuss in gopls's context.

  • If the analyzer eventually allows configurations/flags, how can they be available in gopls?
  • Is the diagnostics the only option for shadowed var presentation feasible through LSP?
  • Is the diagnostic the right UI for this type of high-false positive diagnostics?

@hyangah hyangah transferred this issue from golang/vscode-go May 16, 2024
@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 May 16, 2024
@gopherbot gopherbot added this to the Unreleased milestone May 16, 2024
@hyangah hyangah added the gopls/analysis Issues related to running analysis in gopls label May 16, 2024
@adonovan
Copy link
Member

The shadow analyzer has never been enabled by default in 'go vet' of gopls because it has always suffered from a high rate of false positives that no-one knows how to fix. We would rather not invest any more effort into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/analysis Issues related to running analysis in gopls 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