Commits

Anonymous committed 0a18ac1

Regenerated complexity.vim

  • Participants
  • Parent commits 43069ef

Comments (0)

Files changed (1)

File complexity.vim

 
 
 class Complexity(ASTVisitor):
-    """Encapsulates the cyclomatic complexity counting."""
-
     def __init__(self, code_or_node, stats=None, description=None):
         ASTVisitor.__init__(self)
         try:
             self.dispatch(child)
 
     def visitFunction(self, node):
-        #if not hasattr(node, 'name'): # lambdas
-        #    node.name = '<lambda>'
         score=Complexity(node).score
         stats = Stats(name=node.name,
                       score=score,
                       end_line=self.highest_line_in_node(node))
         self.stats.add(stats)
 
-    #visitLambda = visitFunction
-
     def visitClass(self, node):
         complexity = Complexity(node)
         self.stats.add(Stats(name=node.name,
             repr(self.end_line))
 
 
-def measure_complexity(ast, module_name=None):
-    return CCVisitor(ast, description=module_name).stats
-
-
-class PrettyPrinter(object):
-    def flatten_stats(self, stats):
-        def flatten(stats):
-            for s in stats.classes:
-                name = s.name
-                for x in s.functions:
-                    fname = '.'.join([name, x.name])
-                    yield fname, x.complexity, x.first_line, x.last_line
-            for s in stats.functions:
-                name = s.name
-                yield name, s.complexity, s.first_line, s.last_line
-
-        return [t for t in flatten(stats)]
-
-
 def complexity_name(complexity):
     if complexity > 14:
         return 'high_complexity'