Skip to content

Latest commit

 

History

History
15 lines (14 loc) · 412 Bytes

File metadata and controls

15 lines (14 loc) · 412 Bytes
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.
	}
}