Assignments within sub-expressions are hard to spot and therefore make the code less readable.
It is also a common mistake to write =
when ==
was meant.
Ideally, every expression should have no more than one side-effect.
Assignments inside lambda and delegate expressions are allowed.
The following code:
foo(i = 42); // Non-Compliant
should be refactored into:
i = 42; foo(i); // Compliantor:
foo(i == 42); // Compliant