CS.STMT.WHILE.BLOCK
Body for while statement should be a block.
The body of a while statement must be a block enclosed by {and}.
Vulnerability and risk
If you omit the curly braces while in the body of a while statement, a careless programming error may occur.
Mitigation and prevention
Use curly braces in the body of the while statement.
Example
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace kmcustom 8 { 9 class C18 10 { 11 public void doSomething() 12 { 13 14 } 15 16 public void testNGWhile(int some_number) 17 { 18 19 int i = 0; 20 while (i < some_number) 21 i++; 22 23 int j = 0; 24 while (j < some_number) ; 25 26 } 27 28 public void testOKWhile(int some_number) 29 { 30 31 int i = 0; 32 while (i < some_number) 33 { 34 i++; 35 } 36 } 37 } 38 }