-
-
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
Add gobreakselectinfor linter #4924
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
Pull Request Description
Linter
The Linter Tests Inside Golangci-lint
|
Seems like your linter reports this even if you use labelled breaks which I think shouldn't be an issue when breaking in a package main
func bad() {
var ch chan string
OUTER:
for {
select {
case <-ch:
break OUTER
}
}
} › go run ./cmd/go-break-select-in-for .
/home/simon/.../go-break-select-in-for/example.go:9:4: break statement inside select statement inside for loop
exit status 3 |
Yes, you are right. I fixed in v0.0.2 func bad(ch <-chan bool) {
for {
select {
case <-ch:
break // want "break statement inside select statement inside for loop"
}
}
}
func good(ch <-chan bool) {
OUTER:
for {
select {
case <-ch:
break OUTER
}
}
} › go run ./cmd/go-break-select-in-for .
/Users/ruben/workspaces/linter-demo/example.go:8:4: break statement inside select statement inside for loop
exit status 3 |
FYI https://semver.org/#how-should-i-deal-with-revisions-in-the-0yz-initial-development-phase |
Should starting at 0.1.0 ? |
Ok, I have updated, new version v0.1.0 |
The Go linter go-break-select-in-for checks that break statement inside select statement inside for loop.
For example, in myFunc the break may want to exit the outer for loop, but it doesn't work as expected.