Reporting McCabe Code Complexity for Python projects in Jenkins (aka Hudson)

Not long ago, I wrote a parser for Pymetrics to produce an html formatted document designed to be integrated in Jenkins using its Html plugin. In Jenkins CI we have Python support for unit tests, code coverage and lint reporting, but not for code complexity as far as I know.

Pycabehtml tries to solve this problem by parsing the output of Pymetrics and report the trends on SLOC (source lines of code), Number of Python modules, and McCabe code complexity over builds. On top of that, it showcases all those modules and methods which have McCabe index over 10 in temperature like colors. Methods with index 10 to 20 are highlighted in yellow, 20 to 50 in orange and over 50 in red.

In Python, due to its dynamic nature, no code should be beyond 10. If any method does, then its time for a refactor. The sooner you catch those, the better; or it might be too late.

Pycabehtml is licensed GPLv3 and is hosted in bitbucket at:

Here I leave attached just a couple of portions of the report done on the core Django web application framework.

In Jenkins/Hudson would appear a link to the above report (you need to install the Html plugin). The next screenshot is for the opensource project alerta that can be found at:


About jordilin

I'm a Senior Software Engineer with an MSc in Telecommunications Engineering. I've got a range of interests including Linux, a very powerful and limitless operating system, travelling, gastronomy and technology.
This entry was posted in Continuous Integration, Open Source, programming, Python and tagged , , , , . Bookmark the permalink.

2 Responses to Reporting McCabe Code Complexity for Python projects in Jenkins (aka Hudson)

  1. Pingback: Python:Identifying “sensitive” code in your application – IT Sprite

  2. Pingback: 识别您的应用程序中的"敏感"代码 | CODE问答

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s