Skip to content

Gendarme.Rules.Maintainability.VariableNamesShouldNotMatchFieldNamesRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

VariableNamesShouldNotMatchFieldNamesRule

Assembly: Gendarme.Rules.Maintainability
Version: 2.10

Description

This rule checks for local variables or parameters whose names match (case sensitive) an instance field name. Note that variable names can only be verified when debugging symbols (pdb or mdb) are available.

Examples

Bad example:

public class Bad {
    public int value;
    public void DoSomething (int value)
    {
        // without 'this.' the field will never be set
        this.value = value;
    }
}

Good example:

public class Good {
    public int value;
    public void DoSomething (int integralValue)
    {
        value = integralValue;
    }
}
Clone this wiki locally