github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckRepeatedIfElse.go (about)

     1  package pkg
     2  
     3  func fn1(b1, b2 bool) {
     4  	if b1 && !b2 {
     5  	} else if b1 {
     6  	} else if b1 && !b2 { // MATCH /condition occurs multiple times/
     7  	} else if b1 { // MATCH /condition occurs multiple times/
     8  	} else {
     9  		println()
    10  	}
    11  }
    12  
    13  func fn2(b1, b2 bool, ch chan string) {
    14  	if b1 && !b2 {
    15  	} else if b1 {
    16  	} else if <-ch == "" {
    17  	} else if <-ch == "" {
    18  	} else {
    19  		println()
    20  	}
    21  }
    22  
    23  func fn3() {
    24  	if gen() {
    25  		println()
    26  	} else if gen() {
    27  		println()
    28  	}
    29  }
    30  
    31  func fn4() {
    32  	if s := gen2(); s == "" {
    33  	} else if s := gen2(); s == "" {
    34  		println()
    35  	}
    36  }
    37  
    38  func fn5() {
    39  	var s string
    40  	if s = gen2(); s == "" {
    41  	} else if s != "foo" {
    42  	} else if s = gen2(); s == "" {
    43  	} else if s != "foo" {
    44  		println()
    45  	}
    46  }
    47  
    48  func gen() bool    { return false }
    49  func gen2() string { return "" }