Code Metrics in Python
Project description
Radon is a Python tool that computes various metrics from the source code. Radon can compute:
McCabe’s complexity, i.e. cyclomatic complexity
raw metrics (these include SLOC, comment lines, blank lines, &c.)
Halstead metrics (all of them)
Maintainability Index (the one used in Visual Studio)
Requirements
Radon will run from Python 2.6 to Python 3.3 with a single code base and without the need of tools like 2to3 or six. It can also run on PyPy without any problems (currently only PyPy 2.0.0 is tested).
Radon does not depend on any other Python package (except Baker for the command line, but it is an optional dependency).
Installation
With Pip:
$ pip install radon
Or download the source and run the setup file:
$ python setup.py install
Usage
Radon can be used either from the command line or programmatically. Documentation is WIP at https://radon.readthedocs.org/.
Cyclomatic Complexity Example
Quick example:
$ radon cc -anc ../baker/baker.py ../baker/baker.py M 581:4 Baker.parse_args - D M 723:4 Baker.parse - D M 223:4 Baker.command - C M 796:4 Baker.apply - C M 857:4 Baker.run - C 32 blocks (classes, functions, methods) analyzed. Average complexity: B (6.15625)
Explanation:
cc is the radon command
-a tells radon to calculate the average complexity at the end
-nc tells radon to print only results with a complexity rank of C or worse. Other examples: -na (from A to F), or -nd (from D to F).
Actually it’s even better: it’s got colors!
Links
Documentation: https://radon.readthedocs.org
Issue Tracker: https://github.com/rubik/radon/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for radon-0.4.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33df60aa595b5daae349a58774d9697eb32a6bd2178b0898509dff18341700cc |
|
MD5 | 04d3c218d9ec505ef76aa305edb070cd |
|
BLAKE2b-256 | 4f1ed1f61d64b438e6b5487ec758be481240617cde7e1e0e32175a7f8d11e98d |