admin管理员组文章数量:1564173
作者:Ilya Lebedev
作者邮箱:melevir@gmail
首页:https://github/Melevir/cognitive_complexity
文档:None
下载链接
congnitive-complexity
Library to calculate Python functions cognitive complexity via code.
Installation
pip install cognitive_complexity
Usage
>>> import ast
>>> funcdef = ast.parse("""
... def f(a):
... return a * f(a - 1) # +1 for recursion
... """).body[0]
>>> from cognitive_complexity.api import get_cognitive_complexity
>>> get_cognitive_complexity(funcdef)
1
What is cognitive complexity
Here are some readings about cognitive complexity:
Realization details
This is not precise realization of original algorithm proposed by G. Ann Campbell, but it gives rather similar results. The algorithm gives complexity points for breaking control flow, nesting, recursion, stacks logic operation etc.
Contributing
We would love you to contribute to our project. It's simple:
Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
Create a pull request. Make sure all checks are green.
Fix review comments if any.
Be awesome.
Here are useful tips:
You can run all checks and tests with make check. Please do it before TravisCI does.
We use BestDoctor python styleguide. Sorry, styleguide is available only in Russian for now.
We respect Django CoC. Make soft, not bullshit.
Copy from pypi
本文标签: 复杂度认知函数代码Complexity
版权声明:本文标题:python complexity_cognitive-complexity-通过代码计算Python函数认知复杂度的库-Ilya Lebedev Installation Usage What is... 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1727469370a1116037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论