run-mccabe.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:twittback 作者: dmerejkowsky 项目源码 文件源码
def process(py_source, max_complexity):
    code = py_source.text()
    tree = compile(code, py_source, "exec", ast.PyCF_ONLY_AST)
    visitor = mccabe.PathGraphingAstVisitor()
    visitor.preorder(tree, visitor)
    for graph in visitor.graphs.values():
        if graph.complexity() > max_complexity:
            text = "{}:{}:{} {} {}"
            return text.format(py_source, graph.lineno, graph.column,
                               graph.entity, graph.complexity())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号