github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa4013/testdata/src/example.com/CheckDoubleNegation/CheckDoubleNegation.go.golden (about)

     1  -- turn into single negation --
     2  package pkg
     3  
     4  func fn(b1, b2 bool) {
     5  	if !b1 { //@ diag(`negating a boolean twice`)
     6  		println()
     7  	}
     8  
     9  	if b1 && !b2 { //@ diag(`negating a boolean twice`)
    10  		println()
    11  	}
    12  
    13  	if !b1 { //@ diag(`negating a boolean twice`)
    14  		println()
    15  	}
    16  
    17  	if !b1 {
    18  		println()
    19  	}
    20  
    21  	if !b1 && !b2 {
    22  		println()
    23  	}
    24  }
    25  
    26  -- remove double negation --
    27  package pkg
    28  
    29  func fn(b1, b2 bool) {
    30  	if b1 { //@ diag(`negating a boolean twice`)
    31  		println()
    32  	}
    33  
    34  	if b1 && b2 { //@ diag(`negating a boolean twice`)
    35  		println()
    36  	}
    37  
    38  	if b1 { //@ diag(`negating a boolean twice`)
    39  		println()
    40  	}
    41  
    42  	if !b1 {
    43  		println()
    44  	}
    45  
    46  	if !b1 && !b2 {
    47  		println()
    48  	}
    49  }