# Neat code complexity tool.

David Stanek wrote a nice utility to measure code complexity. This post explains the details. Anyway, I downloaded his code and tried it out. I really like it:
``` \$ cat matt.py """A few functions for use with pygenie.""" def f(x): "Make an 8-way branch, 1 layer deep." if x == 1: return 1 elif x == 2: return 2 elif x == 3: return 3 elif x == 4: return 4 elif x == 5: return 5 elif x == 6: return 6 elif x == 7: return 7 elif x == 8: return 8```

``` def g(a, b, c): "This function has 8 paths." if a: if b: if c: return 1 # a and b and c. else: return 2 # a and b and not c. else: if c: return 3 # a and not b and c else: return 4 # a and not b and not c. else: if b: if c: return 5 # not a and b and c. else: return 6 # not a and not b and c. else: if c: return 7 # not a and b and not c. else: return 8 # not a and not b and not c. ```

```def h(x): if x: return True else: return False ```

And this is what happens when I run the code:
``` \$ ./pygenie.py complexity matt.py File: /home/matt/svn-checkouts/cyclic_complexity/matt.py Type Name Complexity -------------------- F f 9 F g 8 ```

The functions f and g have a complexity exceeding 7, so they print out.

This might make a nice nose plugin.

• thoi

I also very much like it after trying it. Thanks for sharing such kind of codings.
by thoi trang

• always your articles are rocking and informative man. Thanks a lot for your lovely share. Keep on posting man we love to read it .thanks

• GriffithColeman878

Cant access my pc much here, at work right now will surely give a fair comment latter this evening.

Thanks
kamper yully
______________________________________________
passing drug test | Medical Alert | Discount Brokerage

• ThomasMeyersmiop00

Cant access my pc much here, at work right now will surely give a fair comment latter this evening.

Have a nice day
jenny yully
______________________________________________
social media marketing strategies | windshield repair | Algarve Villa Rentals

• OneillAaron6762w

my inernet not working properly I have bookmarked ur story i'll read it latter

respect
katiz slop
______________________________________________
passing drug test | Medical Alert | Discount Brokerage

• Wonder full writing skills you got mate.

Have a nice day
Albert
______________________________________________