-
-
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
golangci-lint run --fix
generates broken code
#3819
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
This happens when two linters has a fixer for the same range. In your case you're enabling 74 linters, the two that report an issue here with a fixer are (at least) › golangci-lint run --no-config --disable-all --print-issued-lines=false --enable gofumpt
main.go:10: File is not `gofumpt`-ed (gofumpt)
› golangci-lint run --no-config --disable-all --print-issued-lines=false --enable gocritic
main.go:10:26: commentFormatting: put a space between `//` and comment text (gocritic) Running Somewhat a duplicate of #3454 and #1490 but I don't think there's a linter agnostic issue about this. I don't know what the proper way for |
If the two linters provide contradicting fixes for the same range I do see the problem with that. But if both have the same exact fix why can't golangci-lint handle that? This would be similar to the case where git-merge works perfectly fine for two commits that makes the same change to a line. Why can't golangci-lint do the same? Even in the case when two linters have contradicting fixes shouldn't it be better that golangci-lint throws an error instead of silently removing the line completely? |
Found exact duplicate #3230 så closing this one. |
Welcome
Description of the problem
golangci-lint run
reports an issue where a comment has no leading space.Then, run
golangci-lint run --fix
to auto fix it. Instead of adding the space it removes the whole line.Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
The text was updated successfully, but these errors were encountered: