[TIP] McCabe Cyclomatic complexity
Michał Kwiatkowski
constant.beta at gmail.com
Mon Apr 28 02:34:49 PDT 2008
On Mon, Apr 28, 2008 at 11:07 AM, Stefano Masini
<stefano.masini at pragma2000.com> wrote:
> it seams almost impossible that the only thing out there that
> calculates the McCabe cyclomatic complexity of Python code is this
> hacky Perl script!
> http://www.journyx.com/curt/complexity.html
>
> Then someone wrote a python wrapper for taking the hack a bit further:
> http://gdub.wordpress.com/2006/07/09/cyclomatic-complexity-for-python-code/
>
> I'm wondering: am I the only one looking for cyclomatic complexity of
> python code? Or is everybody using the above perl script?
> I took a look at the perl code, and it doesn't seem hard to port it to Python.
> Anybody trying to use the interpreter parse tree? Or maybe that way
> it's too complicated.
There is a tool written in Python for calculating cyclomatic
complexity of Python code. You can find it here:
http://www.traceback.org/2008/03/31/measuring-cyclomatic-complexity-of-python-code/
. It uses the compiler module to parse Python source code.
Cheers,
mk
More information about the testing-in-python
mailing list