ForLoopsMustUseBraces - lpohl-Reply/pmd-github-action GitHub Wiki

Rule: ForLoopsMustUseBraces

Message

Avoid using 'for' statements without curly braces

Description

Avoid using 'for' statements without using surrounding braces. If the code formatting or indentation is lost then it becomes difficult to separate the code being controlled from the rest.

Priority

1 (was 3)

Example

for (int i = 0; i < 42; i++) // not recommended
    foo();

for (int i = 0; i < 42; i++) { // preferred approach
    foo();
}