-
Notifications
You must be signed in to change notification settings - Fork 41
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
Label at the end of a block is not a whitespace (nor comment) #92
Comments
I don't know why you would do this in golang though, it seems lika a pattern from BASIC och batch scripting. Maybe that says more about me but I thought I've seen my shared amount of Go code and this pattern never occurred to me. In your example I would just use for _, x := range a {
if x == y {
continue
}
clean = append(clean, x)
} If I wanted to continue in nested loops I would label the outer most loop and continue that one like so: OUTER:
for range a {
for _, x := range b {
if x == y {
continue OUTER
}
}
} If I had code that wasn't related to this loop that I wanted to skip i would use I tried to Google and see when a good use case for So basically this is not intended but since I want this linter to enforce good practices not only by adding whitespaces but to think of what's a good way to tackle an issue and improve readability I don't see this as something that I do want to support. Ending a scope with a label just to be able to Obviously this is my personal opinion so feel free to argue why you think this is a good pattern and what the benefits over the other control flows such as |
Thank you for your excellent advise 👍
Note: Coding in Go is new for me 😉 |
Improve feedback about the rule reasonBlockEndsWithW See bombsimon#92
Sorry for the four PR: I was thinking I was editing my own forked of your Git repo! |
I agree with @olibre, a jump label is not a whitespace and should not be treaten as if it was. |
@Oppodelldog yep, you’re right. This should not be a part of wsl so it should be fixed, that’s why I left the issue open. This lintet should not warn about this! PRs welcome! :) |
@bombsimon I'll give it a try in hacktober. ;) |
…t reduce by 1 line. Now virtually collapsing empty labeled blocks will * reveal diff in line numbers and lead to reasonBlockEndsWithWS * allow empty labeled blocks at the end of another block (bombsimon#92)
…t reduce by 1 line. Now virtually collapsing empty labeled blocks will * reveal diff in line numbers and lead to reasonBlockEndsWithWS * allow empty labeled blocks at the end of another block (#92)
Merged in golangci/golangci-lint#1750, will be available in next release. |
Simplified version of my code:
I think
wsl
considers the labelSKIP
as a whitespace (or comment)...The text was updated successfully, but these errors were encountered: