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: hide gofmt -s diagnostics (and others?) in generated files #38467

Closed
zikaeroh opened this issue Apr 15, 2020 · 4 comments
Closed
Labels
FrozenDueToAge 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

@zikaeroh
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

I generated code with gqlgen. One of the generated files (matches that DO NOT EDIT regex) contains non gofmt-simplified code.

What did you expect to see?

No non-syntax diagnostics; the file is generated.

What did you see instead?

Diagnostics like: "redundant type from array, slice, or map composite literal"

Since I have quick fix on save enabled, and some diagnostics have suggested fixes, if I save the file then I'll accidentally change the file even though it's generated.

Other linters (staticcheck, golangci-lint) will ignore these files, and I can't recall seeing messages from gopls before in these files, so I'm not sure if it's a new issue or not.

#36914 seems related, but was specifically for staticcheck.

Build info

golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@v0.0.0-20200415034506-5d8e1897c761 h1:Ypqqmv003QzoDmadLMADUJ5LozvN33kS5Zr7zr+AtPU=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
    golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
    golang.org/x/tools@v0.0.0-20200415034506-5d8e1897c761 h1:FVw4lelfGRNPqB3C8qX1m+QyeM2vzToIwlFhEZX42y8=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info

go version go1.14.2 linux/amd64

@gopherbot gopherbot added this to the Unreleased milestone Apr 15, 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 Apr 15, 2020
@gopherbot
Copy link

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Apr 15, 2020
@stamblerre
Copy link
Contributor

We can support this, but I'm curious if it would be useful for vet/staticcheck errors to appear in these generated files, since sometimes they can provide warnings about bugs.

@gopherbot
Copy link

Change https://golang.org/cl/230597 mentions this issue: internal/lsp: hide analysis diagnostics from generated files

@gopherbot
Copy link

Change https://golang.org/cl/230999 mentions this issue: internal/lsp: don't offer suggested fixes for generated files

gopherbot pushed a commit to golang/tools that referenced this issue May 1, 2020
As suggested on Slack, a better fix for golang/go#38467 would be to hide
suggested fixes on generated files. This way, the diagnostics are still
visible but files are not unintentionally modified.

Also, deleted the SuggestedFixes field on source.Diagnostic, since it's
entirely unused.

Change-Id: I10756471e0f913465b1cccd7f222eea0f4de77fe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/230999
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v0.4.1 May 13, 2020
@golang golang locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

3 participants