Skip to content

Gendarme.Rules.Correctness.ReviewSelfAssignmentRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

ReviewSelfAssignmentRule

Assembly: Gendarme.Rules.Correctness
Version: git

Description

This rule checks for variables or fields that are assigned to themselves. This won't change the value of the variable (or fields) but should be reviewed since it could be a typo that hides a real issue in the code.

Examples

Bad example:

public class Bad {
    private int value;
    public Bad (int value)
    {
        // argument is assigned to itself, this.value is unchanged
        value = value;
    }
}

Good example:

public class Good {
    private int value;
    public Good (int value)
    {
        this.value = value;
    }
}

Notes

  • This rule is available since Gendarme 2.0

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally