File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments