Skip to main content

Monitor code metrics for Python on your CI server

Project description

Travis-CI badge Coveralls badge PyPI latest version badge Download format Xenon license

Xenon is a monitoring tool based on Radon. It monitors your code’s complexity. Ideally, Xenon is run every time you commit code. Through command line options, you can set various thresholds for the complexity of your code. It will fail (i.e. it will exit with a non-zero exit code) when any of these requirements is not met.

Installation

With Pip:

$ pip install xenon

Or download the source and run the setup file (requires setuptools):

$ python setup.py install

Xenon is tested with all versions of Python from 2.7 to 3.6 as well as PyPy.

Usage

Typically you would use Xenon in two scenarios:

  1. As a git commit hook: to make sure that your code never exceeds some complexity values.

  2. On a continuous integration server: as a part of your build, to keep under control, as above, your code’s complexity. See Xenon’s .travis.yml file for an example usage.

The command line

Everything boils down to Xenon’s command line usage. To control which files are analyzed, you use the options -e, --exclude and -i, --ignore. Both accept a comma-separated list of glob patterns. The value usually needs quoting at the command line, to prevent the shell from expanding the pattern (in case there is only one). Every filename is matched against the exclude patterns. Every directory name is matched against the ignore patterns. If any of the patterns matches, Xenon won’t even descend into them.

The actual threshold values are defined through these options:

  • -a, --max-average: Threshold for the average complexity (across all the codebase).

  • -m, --max-modules: Threshold for modules complexity.

  • -b, --max-absolute: Absolute threshold for block complexity.

All of these options are inclusive.

An actual example

$ xenon --max-absolute B --max-modules A --max-average A

or, more succinctly:

$ xenon -b B -m A -a A

With these options Xenon will exit with a non-zero exit code if any of the following conditions is met:

  • At least one block has a rank higher than B (i.e. C, D, E or F).

  • At least one module has a rank higher than A.

  • The average complexity (among all of the analyzed blocks) is ranked with B or higher.

Other resources

For more information regarding cyclomatic complexity and static analysis in Python, please refer to Radon’s documentation, the project on which Xenon is based on:

Project details


Download files

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

Source Distribution

xenon-0.7.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xenon-0.7.0-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file xenon-0.7.0.tar.gz.

File metadata

  • Download URL: xenon-0.7.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.4

File hashes

Hashes for xenon-0.7.0.tar.gz
Algorithm Hash digest
SHA256 5e6433c9297d965bf666256a0a030b6e13660ab87680220c4eb07241f101625b
MD5 fa01409dfdc595118ee01b8374e08f19
BLAKE2b-256 90b77b7be57e8669b69a28f583c8f84a8616b848ec7c175506258057cc4bf1d6

See more details on using hashes here.

File details

Details for the file xenon-0.7.0-py2.py3-none-any.whl.

File metadata

  • Download URL: xenon-0.7.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.4

File hashes

Hashes for xenon-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 83e98f67b7077c95c25c3402aea6203dd2ed6256708b76ed9751e9dbf1aba125
MD5 21cf0569f6f77bac4682c528a78c1328
BLAKE2b-256 88bf65e43e118f287a011dac902c43f57807c45310ecdd3c3d3350c9f0141c8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page