-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
goimports and gofmt fixes are not applied if typecheck-requiring linter is enabled on broken source files #5257
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hello, the linters don't run independently. If you want to just run a formatter: golangci-lint run --enable-only="goimports" --fix |
Thanks @ldez Is it desired behavior? or is this something that is too complex to implement / not worth it? |
Yes, because golangci-lint runs all the linters "at the same time": the requirements of one run is a kind of "sum" of all the linters requirements.
TLDR: yes too complex to implement and isn't worth it. The formatters are something different than linters but currently, they are handled like linters. I have some ideas about this topic, I will communicate about that at the beginning of the year but don't expect magical things. |
Got it -- and thank you for your work, great project! |
This is a bit interesting since, as you wrote in your PR in I wonder if we could add either a shortcut for all formatters like I don't think something like |
@bombsimon just wait for a few days, I will open 5 issues 😉 They are ready but I want to open them after the 1st. |
First stage is to run goimports and formatter, second is full suite. This ensures that imports and formatting are fixed even in presence of other issues. Otherwise golanci-lint refuses to fix anything golangci/golangci-lint#5257 This helpful when running aider with config like this - aider will use that to autofix what it can after every update: ``` % cat .aider.conf.yml lint-cmd: - "go: ./lint.sh" ```
Welcome
typecheck
section of the FAQ.Description of the problem
Some frequently used linters, like goimports and gofmt do not require the file to be compilation error-free. They can diagnose and fix issues even in presence of errors, This works both standalone and from golangci-lint:
However, adding another linter into the mix, triggers typecheck errors AND disables previously working linters. I understand typecheck stage is required for the new linter but it is not required for all linters.
Note, this especially becomes a problem when working with some kind of AI that edits your source code but does so with errors. This would also be a problem for people who rely on golangci-lint to fix files on save in their IDE, because gopls does apply the fixes as expected.
Getting the best-effort partial fix from golangci-lint would be very helpful.
Version of golangci-lint
Configuration
n/a
Go environment
n/a
Verbose output of running
A minimal reproducible example or link to a public repository
Validation
Supporter
The text was updated successfully, but these errors were encountered: