• Stars
    star
    228
  • Rank 175,267 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Monitoring tool based on radon

xenon

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:

More Repositories

1

radon

Various code metrics for Python code
Python
1,551
star
2

argon

Monitor cyclomatic complexity in Haskell programs
Haskell
97
star
3

lobster

A fast in-memory limit order book (LOB).
Rust
87
star
4

mando

Create Python CLI apps with little to no effort at all!
Python
61
star
5

hydroconf

Effortless configuration management for Rust, inspired by Dynaconf.
Rust
42
star
6

stack-hpc-coveralls

Coveralls support for Stack projects
Haskell
33
star
7

pyg

A Python Package Manager
Python
21
star
8

pkgtools

A Python library to work with Python Packages
Python
13
star
9

orizuru

A reliable, scalable and flexible Redis message queue for Rust.
Rust
13
star
10

wordref

Python library for the WordReference API
Python
11
star
11

sklearn-pdtransform

Sklearn transformers that work with Pandas dataframes
Python
11
star
12

vim-radon

Cyclomatic complexity for Python files inside Vim
Vim Script
9
star
13

dotenv-parser

A .env file parser for Rust
Rust
7
star
14

dotfiles

My configuration files for ArchLinux + bspwm + Polybar
Vim Script
6
star
15

codeforces

Codeforces solutions in Haskell, Python and C
Haskell
4
star
16

aiopulsar

Asynchronous Python client for Apache Pulsar
Python
3
star
17

vim-dg

Vim plugin for the dg language.
Vim Script
3
star
18

rubik.github.io

A blog about Python and Kubernetes
HTML
3
star
19

project-euler-j

Solving Project Euler's challenges in J
2
star
20

poly

Polynomials in Python
Python
2
star
21

pyst

Python Statistics
Python
2
star
22

github.py

Python wrapper for Github API v3
Python
2
star
23

pomodoro-rs

Rust
2
star
24

pypol

pypol is a new, pure-Python library that allows you to manipulate monomials and polynomials. Here is the documentation (pypol v0.5):
Python
2
star
25

moodle-to-latex

Transform Moodle expressions to Latex code
Haskell
1
star
26

pypol-build

A debian build for pypol (see https://github.com/rubik/pypol)
Python
1
star
27

pyroot

a pure-Python module to perform operations with roots
Python
1
star
28

project-euler-haskell

Solving Project Euler problems in Haskell
Haskell
1
star