-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: stylistic diagnostics emitted for generated code #36914
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
Comments
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. |
The issue here seems to be that your "code generated by" comment doesn't match the agreed upon format, nor any of the explicit exceptions that staticcheck handles. See #13560 and #13560 (comment) in particular. |
I based my comment off of tools/internal/lsp/source/util.go: // Matches cgo generated comment as well as the proposed standard:
// https://golang.org/s/generatedcode
var generatedRx = regexp.MustCompile(`// .*DO NOT EDIT\.?`) This updated repro still reports the stylistic warning: // Code generated by robot. DO NOT EDIT
package foo
var FOO_Bar = 1 The generated file suppression is in the staticcheck driver, no in the checks themselves, right? I didn't see any code in gopls trying to skip analyses based on generatedness. |
Ah, nevermind. I see the fact now in If I add the period at the end |
For people watching at home: AFAIK gopls has no notion of hiding diagnostics in generated files, but the checks in staticcheck use a special analysis ( |
FWIW, |
That is correct. |
In particular the staticcheck "ST*" stylistic checks seem to be reporting diagnostics for generated code. I think the staticcheck standalone driver suppresses stylistic errors for generated files.
To reproduce, ensure gopls staticcheck integration is enabled and create a file foo.gen.go:
I expect to see no diagnostic for "REALLY_Good_Name" but I get ST1003.
The text was updated successfully, but these errors were encountered: