Author: spouliot
Date: 2008-01-12 10:45:54 -0500 (Sat, 12 Jan 2008)
New Revision: 92748

Modified:
   trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
   
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongParameterListsRule.cs
   
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidSpeculativeGeneralityRule.cs
   trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
   trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/CodeDuplicatedLocator.cs
   trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/Expression.cs
   trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs
Log:
2008-01-12  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * AvoidLongMethodsRule.cs: Use new Location ctor.
        * AvoidLongParameterListsRule.cs: Use new Location ctor. Change 
        two methods to static.
        * AvoidSpeculativeGeneralityRule.cs: Use new Location ctor. Change
        four methods to static.
        * CodeDuplicatedLocator.cs: Use new Location ctor. Change two 
        methods to static.
        * Expression.cs: Change a method to static.
        * ExpressionFillerVisitor.cs: Change two methods to static.



Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs    
2008-01-12 15:34:19 UTC (rev 92747)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs    
2008-01-12 15:45:54 UTC (rev 92748)
@@ -92,8 +92,8 @@
                        if (IsAutogenerated (method))
                                return runner.RuleSuccess;
 
-                       Location location = new Location 
(method.DeclaringType.Name, method.Name, 0);
-                       Message message = new Message ("The method is too 
long.",location, MessageType.Error);
+                       Location location = new Location (method);
+                       Message message = new Message ("The method is too 
long.", location, MessageType.Error);
                        return new MessageCollection (message);
                }
        }

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongParameterListsRule.cs
===================================================================
--- 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongParameterListsRule.cs 
    2008-01-12 15:34:19 UTC (rev 92747)
+++ 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidLongParameterListsRule.cs 
    2008-01-12 15:45:54 UTC (rev 92748)
@@ -49,7 +49,7 @@
                        }
                }
 
-               private bool IsOverloaded (MethodDefinition method)
+               private static bool IsOverloaded (MethodDefinition method)
                {
                        if (method.DeclaringType is TypeDefinition) {
                                TypeDefinition type = (TypeDefinition) 
method.DeclaringType;
@@ -58,7 +58,7 @@
                        return false;
                }
 
-               private MethodReference GetShortestOverloaded (MethodDefinition 
method)
+               private static MethodReference GetShortestOverloaded 
(MethodDefinition method)
                {
                        if (method.DeclaringType is TypeDefinition) {
                                TypeDefinition type = (TypeDefinition) 
method.DeclaringType;
@@ -84,7 +84,7 @@
                {
                        if (HasLongParameterList (method)) {
                                MessageCollection messageCollection = new 
MessageCollection ();
-                               Location location = new Location 
(method.DeclaringType.Name, method.Name, 0);
+                               Location location = new Location (method);
                                Message message = new Message ("The method 
contains a long parameter list.",location, MessageType.Error);
                                messageCollection.Add (message);
                                return messageCollection;

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidSpeculativeGeneralityRule.cs
===================================================================
--- 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidSpeculativeGeneralityRule.cs
  2008-01-12 15:34:19 UTC (rev 92747)
+++ 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/AvoidSpeculativeGeneralityRule.cs
  2008-01-12 15:45:54 UTC (rev 92748)
@@ -45,13 +45,13 @@
                        if (type.IsAbstract) {
                                ICollection inheritedClasses = 
Utilities.GetInheritedClassesFrom (type);
                                if (inheritedClasses.Count == 1)
-                                       AddMessage (type.Name, "This abstract 
class only has one class inheritting from.  The abstract classes without 
responsability are a sign for the Speculative Generality smell.");
+                                       AddMessage (type, "This abstract class 
only has one class inheritting from.  The abstract classes without 
responsability are a sign for the Speculative Generality smell.");
                        }
                }
 
-               private void AddMessage (string typeName, string summary)
+               private void AddMessage (TypeDefinition type, string summary)
                {
-                       Location location = new Location (typeName, 
String.Empty, 0);
+                       Location location = new Location (type);
                        Message message = new Message (summary, location, 
MessageType.Error);
                        if (messageCollection == null)
                                messageCollection = new MessageCollection ();
@@ -59,7 +59,7 @@
                }
                
                //return true if the method only contains only a single call.
-               private bool OnlyDelegatesCall (MethodDefinition method)
+               private static bool OnlyDelegatesCall (MethodDefinition method)
                {
                        if (!method.HasBody)
                                return false;
@@ -76,12 +76,12 @@
                        return onlyOneCallInstruction;
                }
 
-               private bool InheritsOnlyFromObject (TypeDefinition type)
+               private static bool InheritsOnlyFromObject (TypeDefinition type)
                {
                        return type.BaseType.FullName == "System.Object" && 
type.Interfaces.Count == 0;
                }
 
-               private bool MostlyMethodsDelegatesCall (TypeDefinition type)
+               private static bool MostlyMethodsDelegatesCall (TypeDefinition 
type)
                {
                        int delegationCounter = 0;
                        foreach (MethodDefinition method in type.Methods) {
@@ -95,10 +95,10 @@
                private void CheckUnnecesaryDelegation (TypeDefinition type)
                {
                        if (MostlyMethodsDelegatesCall (type) && 
InheritsOnlyFromObject (type))
-                               AddMessage (type.Name, "This class contains a 
lot of methods that only delgates the call to other.  This kind of Delegation 
could be a sign for Speculative Generality");
+                               AddMessage (type, "This class contains a lot of 
methods that only delgates the call to other.  This kind of Delegation could be 
a sign for Speculative Generality");
                }
 
-               private bool AvoidUnusedParametersRuleScheduled (Runner runner)
+               private static bool AvoidUnusedParametersRuleScheduled (Runner 
runner)
                {
                        foreach (IMethodRule rule in runner.Rules.Method) {
                                if (rule is AvoidUnusedParametersRule)

Modified: trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog  2008-01-12 
15:34:19 UTC (rev 92747)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog  2008-01-12 
15:45:54 UTC (rev 92748)
@@ -1,3 +1,15 @@
+2008-01-12  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * AvoidLongMethodsRule.cs: Use new Location ctor.
+       * AvoidLongParameterListsRule.cs: Use new Location ctor. Change 
+       two methods to static.
+       * AvoidSpeculativeGeneralityRule.cs: Use new Location ctor. Change
+       four methods to static.
+       * CodeDuplicatedLocator.cs: Use new Location ctor. Change two 
+       methods to static.
+       * Expression.cs: Change a method to static.
+       * ExpressionFillerVisitor.cs: Change two methods to static.
+
 2008-01-05  Sebastien Pouliot  <[EMAIL PROTECTED]> 
 
        * AvoidLargeClassesRule.cs: Don't report defect if the fields are 

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/CodeDuplicatedLocator.cs
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/CodeDuplicatedLocator.cs   
2008-01-12 15:34:19 UTC (rev 92747)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/CodeDuplicatedLocator.cs   
2008-01-12 15:45:54 UTC (rev 92748)
@@ -53,7 +53,7 @@
                        }
                }
 
-               private bool ExistsExpressionsReplied (ICollection 
currentExpressions, ICollection targetExpressions)
+               private static bool ExistsExpressionsReplied (ICollection 
currentExpressions, ICollection targetExpressions)
                {
                        IEnumerator currentEnumerator = 
currentExpressions.GetEnumerator ();
                        IEnumerator targetEnumerator = 
targetExpressions.GetEnumerator ();
@@ -72,7 +72,7 @@
                        return false;
                }
 
-               private ICollection GetExpressionsFrom (MethodBody methodBody)
+               private static ICollection GetExpressionsFrom (MethodBody 
methodBody)
                {
                        ExpressionFillerVisitor expressionFillerVisitor = new 
ExpressionFillerVisitor ();
                        methodBody.Accept (expressionFillerVisitor);
@@ -103,7 +103,7 @@
                        if (!CheckedTypes.Contains (targetTypeDefinition.Name)) 
{
                                foreach (MethodDefinition targetMethod in 
targetTypeDefinition.Methods) {
                                        if (ContainsDuplicatedCode 
(currentMethod, targetMethod)) {
-                                               Location location = new 
Location (currentMethod.DeclaringType.Name, currentMethod.Name, 0);
+                                               Location location = new 
Location (currentMethod);
                                                Message message = new Message 
(String.Format ("Exists code duplicated with {0}.{1}", 
targetTypeDefinition.Name, targetMethod.Name), location, MessageType.Error);
                                                messageCollection.Add (message);
                                        }

Modified: trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/Expression.cs
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/Expression.cs      
2008-01-12 15:34:19 UTC (rev 92747)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/Expression.cs      
2008-01-12 15:45:54 UTC (rev 92748)
@@ -97,7 +97,7 @@
                        return equality;
                }
 
-               private bool CheckEqualityForOpCodes (Instruction 
currentInstruction, Instruction targetInstruction)
+               private static bool CheckEqualityForOpCodes (Instruction 
currentInstruction, Instruction targetInstruction)
                {
                        if (currentInstruction.OpCode.Name == 
targetInstruction.OpCode.Name)
                                return true;

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs 
2008-01-12 15:34:19 UTC (rev 92747)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs 
2008-01-12 15:45:54 UTC (rev 92748)
@@ -45,7 +45,7 @@
                        currentExpression = null;
                }
 
-               private bool IsAcceptable (Instruction instruction)
+               private static bool IsAcceptable (Instruction instruction)
                {
                        return instruction.OpCode.FlowControl == 
FlowControl.Call ||
                                instruction.OpCode.FlowControl == 
FlowControl.Branch ||
@@ -68,7 +68,7 @@
                        }
                }
 
-               private bool IsDelimiter (Instruction instruction)
+               private static bool IsDelimiter (Instruction instruction)
                {
                        return instruction.OpCode.Code == Code.Ldarg_0 ||
                                instruction.OpCode.FlowControl == 
FlowControl.Branch;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to