github.com/nozzle/golangci-lint@v1.49.0-nz3/test/testdata/nestif.go (about)

     1  //golangcitest:args -Enestif
     2  //golangcitest:config_path testdata/configs/nestif.yml
     3  package testdata
     4  
     5  func _() {
     6  	var b1, b2, b3, b4 bool
     7  
     8  	if b1 { // want "`if b1` has complex nested blocks \\(complexity: 1\\)"
     9  		if b2 { // +1
    10  		}
    11  	}
    12  
    13  	if b1 { // want "`if b1` has complex nested blocks \\(complexity: 3\\)"
    14  		if b2 { // +1
    15  			if b3 { // +2
    16  			}
    17  		}
    18  	}
    19  
    20  	if b1 { // want "`if b1` has complex nested blocks \\(complexity: 5\\)"
    21  		if b2 { // +1
    22  		} else if b3 { // +1
    23  			if b4 { // +2
    24  			}
    25  		} else { // +1
    26  		}
    27  	}
    28  
    29  	if b1 { // want "`if b1` has complex nested blocks \\(complexity: 9\\)"
    30  		if b2 { // +1
    31  			if b3 { // +2
    32  			}
    33  		}
    34  
    35  		if b2 { // +1
    36  			if b3 { // +2
    37  				if b4 { // +3
    38  				}
    39  			}
    40  		}
    41  	}
    42  
    43  	if b1 == b2 == b3 { // want "`if b1 == b2 == b3` has complex nested blocks \\(complexity: 1\\)"
    44  		if b4 { // +1
    45  		}
    46  	}
    47  }