Jtest logo




Contents  Previous  Next  Index

MISC.WHILE


A "while" statement should have a block

Description

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

It is a good programming practice to add optional block for a "while" statements.

Example

 package MISC;
 
 public class WHILE {
     public void method (int count) {
         while (count++ < 10)    // violation
             System.out.println ("inside of while");
         while while (count-- > 0) {
             System.out.println ("inside of while");
         }
     }
 }

Repair

Add a block for each "while" statements.


Contents  Previous  Next  Index

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