New Rule: NoAssignmentChaining

Developer
Apr 6, 2011 at 6:20 AM

StyleCop currently does not complain about the following snippet:

int a, b;
a = b = 2;

I think using multiple assignments on a single line is generally a sloppy shortcut which sometimes causes a maintainer to miss the fact that a given variable has in fact been assigned to properly (or an additional variable has been assigned to incorrectly).  It is much clearer to call out each assignment on their own line of code.  I propose adding a rule to call this out.

Apr 6, 2011 at 2:00 PM

I concur.

Apr 6, 2011 at 2:48 PM

Good rule.

Apr 8, 2011 at 3:05 PM

I agree also.