Jtest logo




Contents  Previous  Next  Index

PB.NEA


Do not use embedded assignment operator

Description

This rule flags code that uses the embedded assignment operator.

Code using embedded assignments becomes cryptic and difficult to read.

Example

 package PB;
 
 public class PB_NEA {
     void method () {
         int i = 2;
         int j = 2;
         short r = 4;
         double d = 2;
         double x = 3;
         int k = 3;
 
         d = (k = i + j) + r;
         d -= (x = i + j) + r;
         d /= (x /= i + j) + r;
     }
 }

Repair

Do not nest assignments; this could lead to confusion. Break the nested assignments into multiple statements.


Contents  Previous  Next  Index

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