CS.STMT.FOR.BLOCK
Body for for statement should be a block.
The body of a for statement must be a block enclosed by {and}.
Vulnerability and risk
If you omit the braces {} in the body of a for statement, a careless programming error may occur.
Mitigation and prevention
Use curly braces in the body of a for statement.
Example
Copy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace kmcustom
{
class C18
{
public void testNGFor(int some_number)
{
for (int i = 0; i < some_number; i++)
i++;
for (int j = 0; j < some_number; j++) ;
}
public void testOKFor(int some_number)
{
for (int i = 0; i < some_number; i++)
{
i++;
}
for (int j = 0; j < some_number; j++)
{
;
}
}
}
}