Skip to content

Commit d3ba5c6

Browse files
docs: add radon
1 parent 98efd76 commit d3ba5c6

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

LangLab/python/radon.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# radon
2+
3+
[https://github.com/adminho/python-examples/tree/master/love%20formula](https://github.com/adminho/python-examples/tree/master/love%20formula)
4+
[https://pypi.org/project/radon/](https://pypi.org/project/radon/)
5+
6+
`pip install radon`
7+
8+
[https://radon.readthedocs.io/en/latest/](https://radon.readthedocs.io/en/latest/)
9+
[https://github.com/rubik/radon/issues/64](https://github.com/rubik/radon/issues/64)
10+
11+
``` python
12+
from radon.raw import analyze
13+
from radon.metrics import mi_visit
14+
from radon.complexity import cc_visit
15+
from radon.cli.tools import iter_filenames
16+
17+
# iter through filenames starting from the current directory
18+
# you can pass ignore or exclude patterns here (as strings)
19+
# for example: ignore='tests,docs'for filename in iter_filenames(['.']):
20+
21+
with open(filename) as fobj:
22+
source = fobj.read()
23+
24+
# get cc blocks
25+
blocks = cc_visit(source)
26+
27+
# get MI score
28+
mi = mi_visit(source, True)
29+
30+
# get raw metrics
31+
raw = analyze(source)
32+
33+
# Now do what you want with the data
34+
```

0 commit comments

Comments
 (0)