-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Enabling golangci-lint makes flycheck useless for syntax errors #13580
Comments
Reading through the default flycheck/go checkers I think |
This looks like a problem with
This is actually two error messages which should have been separated for flycheck. This seems not have happened, in addition the error messages contain information where it happened, also this information seems to be lost/not parsed causing flycheck to report all issues at the top of the file. I think this is an upstream issue. |
Yes, the linter isn't reporting syntax errors nicely, which is relatively understandable as it is not the compiler and expects syntactically valid code probably. The "standard" flycheck checkers seem to avoid this issue with I believe |
This would mean we have actually two issues here:
I will try to have a look into this in the next view days. Hope that helps. |
The issue comes from error messages reported by the linter which cannot be understood by the flycheck plugin. I have found this issue which is the root of our issue. Basically the devs hope to have it solved in the latest version and request to receive issues for these kind of errors. However I did run 1.27.0 and the issue persists with your test case. I have now changed the code to first run Here is my command output, note that the lines should only contain the file + line number: golangci-lint run --print-issued-lines=false --out-format=line-number
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: inspect@example
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/home/smile13241324/goWorkspace/src/example/example.go:13:9: unknown field NoSuchField in struct literal /home/smile13241324/goWorkspace/src/example/example.go:13:2: x declared but not used]
ERRO Running error: buildssa: analysis skipped: errors in package: [/home/smile13241324/goWorkspace/src/example/example.go:13:9: unknown field NoSuchField in struct literal /home/smile13241324/goWorkspace/src/example/example.go:13:2: x declared but not used] I have also fixed the missing config for the respective flycheck plugin. Here we disabled the other checkers, however we did not activate all the others from |
@tko with these changes I think the support for In addition Would you mind opening an upstream bug with your test case and the two warnings from the linter? Hopefully this can be fixed in the next releases. |
@smile13241324 thanks, I'll see how things work. I am noticing when editing |
I'm finding (setq flycheck-golangci-lint-enable-all t) to be relatively harmful as it doesn't work at all if you have While enable-all may be a relatively good default in the "all features turned on", setting it here makes it relatively difficult to turn off again as, for example
|
@tko thanks for the feedback, I had hopped I could keep this relatively simple, but as it looks like I have made the problem worse ... let's see if I can remove the hassle here.
I will work on this the next days. |
I think I am finished. In my tests I was able to successfully open an example.go file as well as a example_test.go file. For the first go-build was activated for the second go-test. Both run golangci-lint afterwards. I have also removed the static flycheck-golangci-lint variables. Instead I have added more information to the README to make sure that these variables require some kind of config before the linter can be properly used. Last but not least I have tried to explain the current situation as to avoid confusing too much users seeing these error messages at the top of their files when golangci-lint is used and basic errors are included in the file. @tko would mind having another look at this feature? |
@smile13241324 looking much better. On syntax errors I'm seeing the same error message in triplicate or so, one from go-build (or go-test, depending) and others from golangci-lint. I could get rid of it with slightly different next checker invocation: (flycheck-add-next-checker 'go-build '(warning . golangci-lint) t)
(flycheck-add-next-checker 'go-test '(warning . golangci-lint) t) Also I think the cond could be written to take advantage of the conditions built into the go-build/go-test checkers themselves instead of duplicating it partially: (cond ((flycheck-may-use-checker 'go-test) (flycheck-select-checker 'go-test))
((flycheck-may-use-checker 'go-build) (flycheck-select-checker 'go-build))) |
Nice 👍 , I am really learning something here :). |
@smile13241324 It's working quite alright, thanks. I think this issue can be closed unless you want to tag it with I've noticed that when creating new files (SPC f f whatever.go), either normal.go or _test.go, the go-build / go-test linter isn't getting enabled (shows up as "may run: nil" in |
@tko great, I will close it then. |
Description
Enabling
golangci-lint
makes flycheck useless for syntax errors. Error list shows only a small subset of errors, jumping to next/previous error doesn't do anything, focusing and moving in flycheck-buffer fails to open the correct file.flychecker-verify-setup
Reproduction guide 🪲
(go :variables go-use-golangci-lint t)
/tmp/x/x.go
:Observed behaviour: 👀 💔
The flycheck buffer shows only a very small subset of errors and
SPC e n
andSPC e p
fails to jump to next/previous error as it normally would.Focusing and moving in the flycheck buffer tries to jump to a file, but opens an empty buffer instead and complains in minibuffer with
Expected behaviour: ❤️ 😄
Flycheck buffer shows all errors,
SPC e n
andSPC e p
jumps to next/previous error.System Info 💻
The text was updated successfully, but these errors were encountered: