x/tools/gopls: respect staticcheck config file #36373
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? |
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: