Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2008-02-16 18:51:54 +0300
committerSebastien Pouliot <sebastien@ximian.com>2008-02-16 18:51:54 +0300
commit702728bab852325a3b8e76e83e5bd09b6ed289ef (patch)
tree7d03c41b115f739cab923e141fb39969cb2a9775 /gendarme/rules
parentbd3b398ab687a1131e52b9119fd8474c41bfd9ed (diff)
2008-02-16 Sebastien Pouliot <sebastien@ximian.com>
* AvoidLongMethodsRule.cs: Display actual and maximum IL instruction counts if -v -v is supplied. svn path=/trunk/mono-tools/; revision=95896
Diffstat (limited to 'gendarme/rules')
-rw-r--r--gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs21
-rw-r--r--gendarme/rules/Gendarme.Rules.Smells/ChangeLog5
2 files changed, 16 insertions, 10 deletions
diff --git a/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs b/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
index 2b2dbac1..eb062841 100644
--- a/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
+++ b/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
@@ -40,7 +40,7 @@ namespace Gendarme.Rules.Smells {
[Solution ("You should apply an Extract Method refactoring, but there are other solutions.")]
public class AvoidLongMethodsRule : Rule,IMethodRule {
private int maxInstructions = 170;
- const int AsignationRatio = 7;
+ const int AssignationRatio = 7;
const int DefaultAmountOfElements = 13;
static Hashtable typeMethodDictionary;
@@ -117,20 +117,21 @@ namespace Gendarme.Rules.Smells {
// rule applies!
// success if the instruction count is below the defined threshold
+ int max = MaxInstructions;
if (method.IsConstructor && method.IsStatic) {
- if (method.Body.Instructions.Count <= MaxInstructions + (CountStaticFields (method.DeclaringType as TypeDefinition) * AsignationRatio))
- return RuleResult.Success;
+ max += CountStaticFields (method.DeclaringType as TypeDefinition) * AssignationRatio;
}
else if (method.IsConstructor && method.IsStatic) {
- if (method.Body.Instructions.Count <= MaxInstructions + (CountInstanceFields (method.DeclaringType as TypeDefinition) * AsignationRatio))
- return RuleResult.Success;
- }
- else {
- if (method.Body.Instructions.Count <= MaxInstructions)
- return RuleResult.Success;
+ max += CountInstanceFields (method.DeclaringType as TypeDefinition) * AssignationRatio;
}
- Runner.Report (method, Severity.High, Confidence.Normal, "This method is long.");
+ if (method.Body.Instructions.Count <= max)
+ return RuleResult.Success;
+
+ string s = (Runner.VerbosityLevel < 2) ? String.Empty :
+ String.Format ("Method IL Size: {0}. Maximum Size: {1}", method.Body.Instructions.Count, max);
+
+ Runner.Report (method, Severity.High, Confidence.Normal, s);
return RuleResult.Failure;
}
}
diff --git a/gendarme/rules/Gendarme.Rules.Smells/ChangeLog b/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
index 9e82c2fa..e6aa9634 100644
--- a/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
+++ b/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * AvoidLongMethodsRule.cs: Display actual and maximum IL instruction
+ counts if -v -v is supplied.
+
2008-02-15 Sebastien Pouliot <sebastien@ximian.com>
* AvoidSpeculativeGeneralityRule.cs: Fix rule check since we now use