-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Performance.RemoveUnusedLocalVariablesRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.Performance
Version: git
This rule looks for unused local variables inside methods. This can leads to larger code (IL) size and longer JIT time, but note that some optimizing compilers can remove the locals so they won't be reported even if you can still see them in the source code. This could also be a typo in the source were a value is assigned to the wrong variable.
Bad example:
bool DualCheck ()
{
bool b1 = true;
bool b2 = CheckDetails ();
if (b2) {
// typo: a find-replace changed b1 into b2
b2 = CheckMoreDetails ();
}
return b2 && b2;
}
Good example:
bool DualCheck ()
{
bool b1 = true;
bool b2 = CheckDetails ();
if (b2) {
b1 = CheckMoreDetails ();
}
return b1 && b2;
}
- This rule is available since Gendarme 2.0
You can browse the latest source code of this rule on github.com
Note that this page was autogenerated (3/17/2011 1:55:44 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!