Braces

The Braces Checkerset contains a collection of braces checkers.

IfStmtsMustUseBraces

Avoid using if statements without using curly braces

Here's an example of code that would trigger this checker:

			
 
 public class Foo {
   public void bar() {
     int x = 0;
     if (foo) x++;
   }
 }
 
     
		

WhileLoopsMustUseBraces

Avoid using 'while' statements without using curly braces

Here's an example of code that would trigger this checker:

			
  
    public void doSomething() {
      while (true)
          x++;
    }
  
      
		

IfElseStmtsMustUseBraces

Avoid using if..else statements without using curly braces

Here's an example of code that would trigger this checker:

			
   

     public void doSomething() {
       // this is OK
       if (foo) x++;

       // but this is not
       if (foo)
           x=x+1;
       else
           x=x-1;
     }
   
       
		

ForLoopsMustUseBraces

Avoid using 'for' statements without using curly braces

Here's an example of code that would trigger this checker:

			
   
     public void foo() {
       for (int i=0; i<42;i++)
           foo();
     }