Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.
func compute(a int, b int) {
sum := a + b
if sum > 0 { } // Noncompliant; empty on purpose or missing piece of code?
fmt.Println("Result:", sum)
}
func compute(a int, b int) {
sum := a + b
if sum > 0 {
fmt.Println("Positive result")
}
fmt.Println("Result:", sum)
}
When a block contains a comment, this block is not considered to be empty. for and select statements with empty blocks
are ignored as well.