CS.STMT.DO.BLOCK
Body for do statement should be a block.
The body of a do statement should be followed by a block statement.
Vulnerability and risk
If you omit the braces {} in the body of a do statement, a careless programming error may occur.
Mitigation and prevention
Make sure to use curly braces in the body of a do 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 testNGDo(int some_number) 12 { 13 14 int i = 0; 15 do 16 i++; 17 while (i < some_number); 18 19 int j = 0; 20 do 21 ; 22 while (j < some_number); 23 24 } 25 26 public void testOKDo(int some_number) 27 { 28 29 int i = 0; 30 do 31 { 32 i++; 33 } while (i < some_number); 34 35 int j = 0; 36 do 37 { 38 ; 39 } while (j < some_number); 40 41 } 42 } 43 }