Jtest logo




Contents  Previous  Next  Index

PB.SBC


Avoid a "switch" statement with a bad "case"

Description

This rule flags code where a missing "break" or "return" causes control to flow into another case in a "switch".

Example

 package PB;
 public class SBC{
     void method (int i) {
         switch (i) {
         case 1:
 	 a = 10;
 break;
         case 2:
 a = 20; //missing break
         default:
 a = 40;
 break;
         }
     }
 }

Repair

Add the missing "break" or "return".


Contents  Previous  Next  Index

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