Marty Andrews

artful code

Saturday, February 10, 2007

Complexian. Simian's little brother.

With a bit of moral support from Simon Harris, the author of Simian, I've put together a tool called Complexian. It measures NPath complexity in your Java code, and warns you if it gets too high. The internals have been born from the same seeds of design as Simian, so it runs blindingly fast.

The NPath complexity of your code is exactly the number of unit tests required to get complete coverage of it. Complexian exists to measure the NPath complexity of your code and to warn you when it gets too high. Keeping the number low means that you can cover many more of the paths through your system with unit tests. That can save valuable time and money as projects get bigger and go for longer periods of time.

You can use Checkstyle already to check NPath complexity, but here's a few reasons you might prefer to use Complexian.

  1. Its significantly faster. Complexian can check the 1.2 million shared lines of code in JDK1.5 in under 15 seconds.
  2. Output is ordered so you see the “worst” offenders more obviously.
  3. You get summary of the total system, and how offensive the violations are in relation to it.
  4. Checkstyle has an overflow bug in it, so you don’t get the real story. (we’ve submitted a patch though, so this will go away eventually).

The most important reason for me is that complexity is treated like a second class citizen when its bundled in with other checkstyle checks. Too many times have I seen either the specific check turned off, or checkstyle itself turned off because developers didn’t like some formatting rule. Its important enough to me that I want that decision to be much more obvious, and treated with more consideration. If producing a tool that deals with the issue directly helps to highlight it, then I'm happy with the outcome.

You can see more details about Complexian and download it from the resources section of this site. Please send any feedback you have to me.

No comments:

Post a Comment