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
}
}
This diagnostic rule is classified as:
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: