Fixed an issue with the complexity checker causing it to crash.

Fri, 31 Mar 2017 17:28:12 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 31 Mar 2017 17:28:12 +0200
changeset 5671
47cc72334684
parent 5670
7296fc0fae6d
child 5672
495b53f37f6c

Fixed an issue with the complexity checker causing it to crash.

Plugins/CheckerPlugins/CodeStyleChecker/ComplexityChecker.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/CodeStyleChecker/ComplexityChecker.py	Fri Mar 31 17:26:54 2017 +0200
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/ComplexityChecker.py	Fri Mar 31 17:28:12 2017 +0200
@@ -233,26 +233,14 @@
         @return median line complexity value
         @rtype float
         """
-        total = 0
-        for line in self.__count:
-            total += self.__count[line]
-
-        return self.__median(self.__count.values())
-    
-    def __median(self, lst):
-        """
-        Private method to determine the median of a list.
-        
-        @param lst list to determine the median for
-        @type list of int
-        @return median of the list
-        @rtype float
-        """
+        lst = self.__count.values()
         sortedList = sorted(lst)
         listLength = len(lst)
         medianIndex = (listLength - 1) // 2
-
-        if (listLength % 2):
+        
+        if listLength == 0:
+            return 0.0
+        elif (listLength % 2):
             return float(sortedList[medianIndex])
         else:
             return (

eric ide

mercurial