V8006. Unconditional 'break/continue/return/goto' within a loop.
The analyzer has detected a suspicious loop where one of the following statements is executed unconditionally: continue, break, return, goto.
The example:
for i := 0; i < max; i++ {
if i == index {
value += Calculate(i)
}
break
}
In this code, the break statement does not belong to the if statement body, so it runs whether the i == index condition is true. As a result, the loop body always executes only once.
The fixed code may look like this:
for i := 0; i < max; i++ {
if i == index {
value += Calculate(i)
break
}
}