-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: respect staticcheck config file #36373
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. |
Not sure if vim supports json config for gopls, however the way to do this in vscode is:
Which is based on https://github.com/golang/tools/blob/master/gopls/doc/settings.md |
I read that page but missed that flag! I will look into setting that flag in govim. It seems to me that the issue is still worthwhile because not checking the config file seems a surprising behavior? |
It might be because gopls imports staticcheck directly rather than invoking the external binary, but not 100% sure. |
Yes, gopls uses the static check analyzeers directly, and does not have or support all the features of the staticcheck binary. It runs the checkers in a very different way and will probably never fully overlap. There are some things in the config that it might be reasonable to converge, but it needs to be done in a way that works for non staticcheck analyzers too, so it needs some thought. |
this is not working anymore. Are there still ways to disable individual checks of staticcheck ? |
@adityaU yep, the field was changed a little: "gopls": {
"staticcheck": true,
"analyses": {
"ST1000": false,
"ST1003": false
}
// other options
} |
@OneOfOne Thank you so much. :) |
It also doesn't appear to respect line based directives, like https://staticcheck.io/docs/#line-based-linter-directives, or does it have a different syntax for that? |
Looks like this is not working anymore?
|
@GAZ082 sorry for the slow response, but disabling individual analyses should definitely still work. |
Looking into this now, it seems like we should actually already be loading the config file via the Or maybe it isn't. Warrants investigation. If it does work, we could theoretically inject our view of the filesystem (including overlays) into CC @dle8 |
In Staticcheck, there are two parts to configuration. Configuration that gets used by individual analyzes via |
@dominikh is the *truth be told, I'm not actually sure whether it's a bad idea to use |
It currently is, yes.
That is my understanding, too.
It would seem weird to use two different analysis runners IMO. Also, |
Thanks. In that case, I think we should not do anything here other than verify that config.Analyzer is WAI. |
In vscode, gostaticcheck is respecting config file named "staticcheck.conf" but zed https://zed.dev/ which is using Can someone please guide me how vscode can respect this config file but not zed editor? any setting that i am missing? I am using this as workaround for now.
note: ST1017 which is part of my config file which i require skipping. |
@zerocorebeta VS Code Go plugin does not use gopls' staticcheck integration by default, but calls the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
govim is using commit
f13409bb
, which is pretty new, and it reproducesWhat operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I don't know how to use
gopls
directly, so here's how to reproduce throughgovim
staticcheck.conf
file with these contents:staticcheck .
orstaticcheck main.go
do not raise any errorscall govim#config#Set("Staticcheck", 1)
ST1005
on line 6Reading the gopls logs from govim shows:
As you can see from the config,
ST1005
ought to be ignored for this file.(I feel pretty certain that
govim
isn't doing anything wrong in how it launches or communicates withgopls
? But if I've got this error filed on the wrong side of that divide, I apologize)What did you expect to see?
No ST1005 errors flagged on main.go
What did you see instead?
An ST1005 error flagged on main.go
The text was updated successfully, but these errors were encountered: