Skip to main content
Help us improve Python packaging – donate today!

Code Metrics in Python

Project Description

Radon is a tool for Python that computes various metrics from the source code. Radon does not only compute McCabe’s complexity, but also:

  • raw metrics (these include SLOC, comment lines, blank lines, &c.)
  • Halstead metrics (all of them)
  • Maintainability Index (the one used in Visual Studio)

Usage

Radon can be used either from the command line or programmatically. Documentation is WIP.

Cyclomatic Complexity

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)

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

A screen of Radon's cc command

Command’s help:

$ radon cc -h
Usage: /home/miki/exp/bin/radon cc [<min>] [<max>] [<show_complexity>] [<average>] [<paths>...]

Analyze the given Python modules and compute Cyclomatic Complexity (CC).

    The output can be filtered using the *min* and *max* flags. In addition
    to y default, complexity score is not displayed.

Options:

   -x --max              The maximum complexity to display (default to F).
   -a --average          If True, at the end of the analysis display the
                           average complexity. Default to False.
   -s --show_complexity  Whether or not to show the actual complexity score
                           together with the A-F rank. Default to False.
   -n --min              The minimum complexity to display (default to A).

Variable arguments:

   *paths The modules or packages to analyze.

Release history Release notifications

History Node

2.2.0

History Node

2.1.1

History Node

2.0.3

History Node

2.0.2

History Node

2.0.1

History Node

2.0.0

History Node

1.5.0

History Node

1.4.2

History Node

1.4.0

History Node

1.3.2

History Node

1.3.1

History Node

1.3.0

History Node

1.2.3

History Node

1.2.2

History Node

1.2.1

History Node

1.2

History Node

1.1.1

History Node

1.1

History Node

1.0

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5

History Node

0.4.5

History Node

0.4.4

History Node

0.4.3

History Node

0.4.2

History Node

0.4.1

History Node

0.4

History Node

0.3.1

This version
History Node

0.3

History Node

0.2

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
radon-0.3-py2.py3-none-any.whl (22.0 kB) Copy SHA256 hash SHA256 Wheel 2.7 Nov 2, 2012
radon-0.3.tar.gz (17.4 kB) Copy SHA256 hash SHA256 Source None Nov 2, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page