mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
first working version
This commit is contained in:
141
testdata/unconditional-recursion.go
vendored
Normal file
141
testdata/unconditional-recursion.go
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
package fixtures
|
||||
|
||||
import "time"
|
||||
|
||||
func ur1() {
|
||||
ur1() // MATCH /unconditional recursive call/
|
||||
}
|
||||
|
||||
func ur1bis() {
|
||||
if true {
|
||||
print()
|
||||
} else {
|
||||
switch {
|
||||
case true:
|
||||
println()
|
||||
default:
|
||||
for i := 0; i < 10; i++ {
|
||||
print()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ur1bis() // MATCH /unconditional recursive call/
|
||||
}
|
||||
|
||||
func ur2tris() {
|
||||
for {
|
||||
println()
|
||||
ur2tris() // MATCH /unconditional recursive call/
|
||||
}
|
||||
}
|
||||
|
||||
func ur2() {
|
||||
if true {
|
||||
return
|
||||
}
|
||||
|
||||
ur2()
|
||||
}
|
||||
|
||||
func ur3() {
|
||||
ur1()
|
||||
}
|
||||
|
||||
func urn4() {
|
||||
if true {
|
||||
print()
|
||||
} else if false {
|
||||
return
|
||||
}
|
||||
|
||||
ur4()
|
||||
}
|
||||
|
||||
func urn5() {
|
||||
if true {
|
||||
return
|
||||
}
|
||||
|
||||
if true {
|
||||
println()
|
||||
}
|
||||
|
||||
ur5()
|
||||
}
|
||||
|
||||
func ur2tris() {
|
||||
for true == false {
|
||||
println()
|
||||
ur2tris()
|
||||
}
|
||||
}
|
||||
|
||||
type myType struct {
|
||||
foo int
|
||||
bar int
|
||||
}
|
||||
|
||||
func (mt *myType) Foo() int {
|
||||
return mt.Foo() // MATCH /unconditional recursive call/
|
||||
}
|
||||
|
||||
func (mt *myType) Bar() int {
|
||||
return mt.bar
|
||||
}
|
||||
|
||||
func ur6() {
|
||||
switch {
|
||||
case true:
|
||||
return
|
||||
default:
|
||||
println()
|
||||
}
|
||||
|
||||
ur6()
|
||||
}
|
||||
|
||||
func ur7(a interface{}) {
|
||||
switch a.(type) {
|
||||
case int:
|
||||
return
|
||||
default:
|
||||
println()
|
||||
}
|
||||
|
||||
ur7()
|
||||
}
|
||||
|
||||
func ur8(a []int) {
|
||||
for _, i := range a {
|
||||
return
|
||||
}
|
||||
|
||||
ur8()
|
||||
}
|
||||
|
||||
func ur9(a []int) {
|
||||
for _, i := range a {
|
||||
ur9()
|
||||
}
|
||||
}
|
||||
|
||||
func ur10() {
|
||||
select {
|
||||
case <-aChannel:
|
||||
case <-time.After(2 * time.Second):
|
||||
return
|
||||
}
|
||||
ur10()
|
||||
}
|
||||
|
||||
func ur11() {
|
||||
go ur11()
|
||||
}
|
||||
|
||||
func ur12() {
|
||||
go foo(ur12()) // MATCH /unconditional recursive call/
|
||||
go bar(1, "string", ur12(), 1.0) // MATCH /unconditional recursive call/
|
||||
go foo(bar())
|
||||
}
|
||||
Reference in New Issue
Block a user