run-mccabe.py 文件源码

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

项目:tsrc 作者: SuperTanker 项目源码 文件源码
def process(py_source, max_complexity):
    res = list()
    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:
            res.append((py_source, graph))
    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号