CS.ASSIGN.SELF

A language entity is assigned to itself.

Vulnerability and risk

Self assignment does not have any effect. Even if this is not an error on its own, it may indicate a larger error in the code.

Example 1

Copy
  class Foo {
      struct Boo {
          public int x;
          public Boo(int _x) {
              x = _x;
          }
      }
    
      void Assigner() {
         decimal d = 0;
         d = d;             // defect
         Boo boo1 = new Boo(1), 
             boo2 = new Boo(2);
         boo1.x = boo2.x;   // OK
         boo2.x = boo2.x;   // defect
     }
 }