Jtest logo




Contents  Previous  Next  Index

PB.ASI


Avoid assignments within an "if" condition

Description

This rule flags any assignment in "if" conditional statements.

Example

 package PB;
 
 public class ASI {
   public int foo(boolean b) {
      int ret = 0;
      if ((b = true) {    // Violation
         ret = 3;
      }
      return ret;
   }
 }

Repair

Replace the "=" with "==" or move the variable assignment outside of the "if".

Reference

http://g.oswego.edu/dl/html/javaCodingStd.html


Contents  Previous  Next  Index

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