Skip to content

unchanged-loop-condition

Detect counted loops whose condition variable never changes.

Updated View as Markdown

Default severity: warning

A conventional three-part loop that initializes and tests one variable but never changes that variable cannot progress as intended. This often means the post statement increments the wrong counter or is unreachable.

Bad

for index := 0; index < limit; other++ { use(index) }

Good

for index := 0; index < limit; index++ { use(index) }
Navigation

Type to search…

↑↓ navigate↵ selectEsc close