Why is this an issue?

Using a for loop without its typical structure (initialization, condition, increment) can be confusing. In those cases, it is better to use a while loop as it is more readable.

The initializer section should contain a variable declaration to be considered as a valid initialization.

How to fix it

Replace the for loop with a while loop.

Code example

Noncompliant code example

for (;condition;) // Noncompliant; both the initializer and increment sections are missing
{
    // Do something
}

Compliant solution

while (condition)
{
    // Do something
}

Noncompliant code example

int i;

for (i = 0; i < 10;) // Noncompliant; the initializer section should contain a variable declaration
{
    // Do something
    i++;
}

Compliant solution

int i = 0;

while (i < 10)
{
    // Do something
    i++;
}

Resources

Documentation