2018-06-08 21:41:49 +02:00
|
|
|
// Test of empty-blocks.
|
|
|
|
|
|
|
|
package fixtures
|
|
|
|
|
2023-03-16 22:39:52 +02:00
|
|
|
import "net/http"
|
|
|
|
|
2020-05-11 02:43:56 +02:00
|
|
|
func f(x int) {} // Must not match
|
2018-06-08 21:41:49 +02:00
|
|
|
|
2020-05-11 02:43:56 +02:00
|
|
|
type foo struct{}
|
2018-06-11 21:08:59 +02:00
|
|
|
|
2020-05-11 02:43:56 +02:00
|
|
|
func (f foo) f(x *int) {} // Must not match
|
|
|
|
func (f *foo) g(y *int) {} // Must not match
|
2018-06-08 21:41:49 +02:00
|
|
|
|
2023-03-16 22:39:52 +02:00
|
|
|
func h() {
|
|
|
|
go http.ListenAndServe()
|
|
|
|
select {} // Must not match
|
|
|
|
}
|
|
|
|
|
2020-05-11 02:43:56 +02:00
|
|
|
func g(f func() bool) {
|
2018-06-08 21:41:49 +02:00
|
|
|
{ // MATCH /this block is empty, you can remove it/
|
|
|
|
}
|
|
|
|
|
2020-05-11 02:43:56 +02:00
|
|
|
_ = func(e error) {} // Must not match
|
2018-06-11 21:08:59 +02:00
|
|
|
|
2018-06-08 21:41:49 +02:00
|
|
|
if ok := f(); ok { // MATCH /this block is empty, you can remove it/
|
|
|
|
// only a comment
|
|
|
|
} else {
|
|
|
|
println("it's NOT empty!")
|
|
|
|
}
|
|
|
|
|
|
|
|
if ok := f(); ok {
|
|
|
|
println("it's NOT empty!")
|
|
|
|
} else { // MATCH /this block is empty, you can remove it/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < 10; i++ { // MATCH /this block is empty, you can remove it/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for { // MATCH /this block is empty, you can remove it/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-04-28 15:38:51 +02:00
|
|
|
for true { // MATCH /this block is empty, you can remove it/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-20 19:59:50 +02:00
|
|
|
// issue 386, then overwritten by issue 416
|
2020-05-11 02:43:56 +02:00
|
|
|
var c = make(chan int)
|
2020-05-20 19:59:50 +02:00
|
|
|
for range c { // MATCH /this block is empty, you can remove it/
|
2020-05-11 02:43:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var s = "a string"
|
|
|
|
for range s { // MATCH /this block is empty, you can remove it/
|
|
|
|
}
|
|
|
|
|
2023-03-16 22:39:52 +02:00
|
|
|
select {
|
|
|
|
case _, ok := <-c:
|
|
|
|
if ok { // MATCH /this block is empty, you can remove it/
|
|
|
|
}
|
|
|
|
}
|
2023-04-28 15:38:51 +02:00
|
|
|
|
|
|
|
// issue 810
|
|
|
|
next := 0
|
|
|
|
iter := func(v *int) bool {
|
|
|
|
*v = next
|
|
|
|
next++
|
|
|
|
fmt.Println(*v)
|
|
|
|
return next < 10
|
|
|
|
}
|
|
|
|
|
|
|
|
z := 0
|
|
|
|
for iter(&z) { // Must not match
|
|
|
|
}
|
|
|
|
|
|
|
|
for process() { // Must not match
|
|
|
|
}
|
|
|
|
|
|
|
|
var it iterator
|
|
|
|
for it.next() { // Must not match
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func process() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
type iterator struct{}
|
|
|
|
|
|
|
|
func (it *iterator) next() bool {
|
|
|
|
return false
|
2018-06-08 21:41:49 +02:00
|
|
|
}
|