Why is this an issue?

Assignments within sub-expressions are hard to spot and therefore make the code less readable. Ideally, sub-expressions should not have side-effects.

Noncompliant code example

if ((str = cont.substring(pos1, pos2)).isEmpty()) {  // Noncompliant
  //...

Compliant solution

str = cont.substring(pos1, pos2);
if (str.isEmpty()) {
  //...

Exceptions

Assignments in while statement conditions, and assignments enclosed in relational expressions are ignored.

BufferedReader br = new BufferedReader(/* ... */);
String line;
while ((line = br.readLine()) != null) {...}
if ((i = j) >= 1) {...}

Chained assignments, including compound assignments, are ignored.

int i = j = 0;
int k = (j += 1);
result = (bresult = new byte[len]);

Resources