mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
refactor: rename files to follow Go convention
This commit is contained in:
committed by
chavacava
parent
c0d4d07ab6
commit
be95bfa705
93
testdata/empty_block.go
vendored
Normal file
93
testdata/empty_block.go
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Test of empty-blocks.
|
||||
|
||||
package fixtures
|
||||
|
||||
import "net/http"
|
||||
|
||||
func f(x int) {} // Must not match
|
||||
|
||||
type foo struct{}
|
||||
|
||||
func (f foo) f(x *int) {} // Must not match
|
||||
func (f *foo) g(y *int) {} // Must not match
|
||||
|
||||
func h() {
|
||||
go http.ListenAndServe()
|
||||
select {} // Must not match
|
||||
}
|
||||
|
||||
func g(f func() bool) {
|
||||
{ // MATCH /this block is empty, you can remove it/
|
||||
}
|
||||
|
||||
_ = func(e error) {} // Must not match
|
||||
|
||||
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/
|
||||
|
||||
}
|
||||
|
||||
for true { // MATCH /this block is empty, you can remove it/
|
||||
|
||||
}
|
||||
|
||||
// issue 386, then overwritten by issue 416
|
||||
var c = make(chan int)
|
||||
for range c { // MATCH /this block is empty, you can remove it/
|
||||
}
|
||||
|
||||
var s = "a string"
|
||||
for range s { // MATCH /this block is empty, you can remove it/
|
||||
}
|
||||
|
||||
select {
|
||||
case _, ok := <-c:
|
||||
if ok { // MATCH /this block is empty, you can remove it/
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user