-
-
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
Conflict gofumpt and wsl for empty lines before if statement #1510
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hi! I'm the author of package main
import (
"encoding/base64"
"log"
)
func main() {
str := "just example of code for test"
encodedStr := base64.StdEncoding.EncodeToString([]byte(str))
_, err := base64.StdEncoding.DecodeString(encodedStr)
if err != nil {
log.Fatalf("Decodding error: %s", err)
}
} I agree that it's not obvious and I understand that it's hard to argue about using EDIT not really the same but this is also valid according to both Source codepackage main
import (
"encoding/base64"
"log"
)
func main() {
str := "just example of code for test"
encodedStr := base64.StdEncoding.EncodeToString([]byte(str))
if _, err := base64.StdEncoding.DecodeString(encodedStr); err != nil {
log.Fatalf("Decodding error: %s", err)
}
} |
This code is just an example to describe the problem. Hm, looks like Let's ask gofumpt's author @mvdan |
I don't think gofumpt should fix anything here. The original source code is fine, as far as I can tell, and forcing the addition of an empty line feels out of scope for a generic formatter. If someone really wants to go the extra mile with empty lines, they can already use wsl. It seems like if that tool slightly improves its error message, or suggests the right change to make, then it won't enter into a conflict loop with gofumpt. |
I'm also not sure how useful it is to run two opinionated formatting/style tools at once. They'll probably run into conflicts sooner or later, unless both tools are compatible by design - just like gofumpt by design never fights gofmt. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I really disagree with the use of the stale bot. This bug is still very much valid, and time passing has not magically made it go away. |
I will re-open. What is your solution to this problem? |
Running both wsl and gofumpt at the same time is likely a bad idea; see #1510 (comment). |
This comment was marked as duplicate.
This comment was marked as duplicate.
I feel like I'm the one that should try to sort this out. Personally I use I'm not sure what happens when two linters with a fixer reports a suggested fix on the same line but I guess worst case a solution would be to run the fixer one by one. |
I never got back to this but I don't think there's much more here to address in this issue. There's been plenty of discussions about presets (e.g. #3954, #1141, and more) and maybe such presets could avoid overlaps and conflicts. However right now we don't have such feature so until then the user must ensure compatibility between enabled linters. @ldez I'd like to close this (and potentially all issues regarding linter conflicts) since I don't think they should be considered a bug per se but just a "limitation" of |
I agree with you 👍 |
Thank you for creating the issue!
Please include the following information:
Version of golangci-lint
Config file
Go environment
Verbose output of running
Description of problem
The problem: gofumpt conflicts with wsl lister for empty lines before if statement with several assignments.
Example of code
How to reproduce:
$ golangci-lint run --enable wsl,gofumpt main.go:12: File is not `gofumpt`-ed (gofumpt)
gofumpt -w main.go
to fix this problem:Ooops! WSL returns the error, again.
The text was updated successfully, but these errors were encountered: