Assignments within sub-expressions are hard to spot and therefore make the code less readable. Ideally, sub-expressions should not have side-effects.
if ((str = cont.substring(pos1, pos2)) != '') { // Noncompliant
//...
}
str = cont.substring(pos1, pos2);
if (str != '') {
//...
}
Assignments in while statement conditions, and assignments enclosed in relational expressions are allowed.
while ((line = nextLine()) != null) {...} // Compliant
while (line = nextLine()) {...} // Compliant
if (line = nextLine()) {...} // Noncompliant