diff -r ab999dc48132 -r 6bca68319bb4 Plugins/CheckerPlugins/CodeStyleChecker/mccabe.py --- a/Plugins/CheckerPlugins/CodeStyleChecker/mccabe.py Fri Mar 17 19:09:39 2017 +0100 +++ b/Plugins/CheckerPlugins/CodeStyleChecker/mccabe.py Fri Mar 17 19:10:39 2017 +0100 @@ -8,7 +8,7 @@ import collections import ast -__version__ = '0.3.1_eric6' +__version__ = '0.6.1_eric6' class ASTVisitor(object): @@ -53,10 +53,11 @@ class PathGraph(object): - def __init__(self, name, entity, lineno): + def __init__(self, name, entity, lineno, column=0): self.name = name self.entity = entity self.lineno = lineno + self.column = column self.nodes = collections.defaultdict(list) def connect(self, n1, n2): @@ -108,7 +109,7 @@ else: entity = node.name - name = '%d:1: %r' % (node.lineno, entity) + name = '%d:%d: %r' % (node.lineno, node.col_offset, entity) if self.graph is not None: # closure @@ -120,7 +121,7 @@ self.graph.connect(pathnode, bottom) self.tail = bottom else: - self.graph = PathGraph(name, entity, node.lineno) + self.graph = PathGraph(name, entity, node.lineno, node.col_offset) pathnode = PathNode(name) self.tail = pathnode self.dispatch_list(node.body) @@ -151,16 +152,17 @@ name = "Stmt %d" % lineno self.appendPathNode(name) - visitAssert = visitAssign = visitAugAssign = visitDelete = visitPrint = \ - visitRaise = visitYield = visitImport = visitCall = visitSubscript = \ - visitPass = visitContinue = visitBreak = visitGlobal = visitReturn = \ - visitSimpleStatement + def default(self, node, *args): + if isinstance(node, ast.stmt): + self.visitSimpleStatement(node) + else: + super(PathGraphingAstVisitor, self).default(node, *args) def visitLoop(self, node): name = "Loop %d" % node.lineno self._subgraph(node, name) - visitFor = visitAsyncFor = visitWhile = visitLoop + visitAsyncFor = visitFor = visitWhile = visitLoop def visitIf(self, node): name = "If %d" % node.lineno @@ -170,7 +172,7 @@ """create the subgraphs representing any `if` and `for` statements""" if self.graph is None: # global loop - self.graph = PathGraph(name, name, node.lineno) + self.graph = PathGraph(name, name, node.lineno, node.col_offset) pathnode = PathNode(name) self._subgraph_parse(node, pathnode, extra_blocks) self.graphs["%s%s" % (self.classname, name)] = self.graph @@ -211,7 +213,7 @@ name = "With %d" % node.lineno self.appendPathNode(name) self.dispatch_list(node.body) - + visitAsyncWith = visitWith #