| rule_id | 1530 |
|---|---|
| rule_category | maintainability |
| title | Don't change a loop variable inside a `for` loop |
| severity | 2 |
Updating the loop variable within the loop body is generally considered confusing, even more so if the loop variable is modified in more than one place.
for (int index = 0; index < 10; ++index)
{
if (someCondition)
{
index = 11; // Wrong! Use 'break' or 'continue' instead.
}
}