Not Logged In

radon 1.0

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.4 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 PyPy 2.4.0 is used in tests).

Radon depends on as few packages as possible. Currently only mando is
strictly required (for the CLI interface). colorama is also listed as a
dependency but if Radon cannot import it, the output simply will not be
colored.

-a tells radon to calculate the average complexity at the end. Note that
the average is computed among the shown blocks. If you want the total
average, among all the blocks, regardless of what is being shown, you should
use --total-average.

-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).

The letter in front of the line numbers represents the type of the block
(F means function, M method and C class).

Actually it’s even better: it’s got colors!

On a Continuous Integration server

If you are looking to use radon on a CI server you may be better off with
xenon. Although still experimental, it will
fail (that means exiting with a non-zero exit code) when various thresholds are
surpassed. radon is more of a reporting tool, while xenon is a monitoring
one.