Jtest logo




Contents  Previous  Next  Index

MISC.ELSEBLK


"else" statements should have a block

Description

This rule flags any "else" statement that does not have a block.

"else" statements are less error-prone when they have blocks.

Example

 package MISC;
 
 public class ELSEBLK {
     public void method (boolean b) {
         if (b) {    
             System.out.println ("inside of if");
         } else 
             System.out.println ("inside of if");  //violation.
     }
 }
 
 

Repair

Provide a block for each "else" statement.


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft