« RESTafarianism and EMF | Main | Some things I learned at the Eclipse Summit Europe 2007 »

Is your code C.R.A.P.?

Just got a link this morning to the C.R.A.P. metric and the crap4j Eclipse plugin. This humourously-named approach mixes up cyclomatic complexity and code coverage to give a number that is your code's CRAP index. Generally speaking, you can lower your CRAP index either by adding automated tests or by refactoring to reduce complexity, or both.

Apparently crap4j can also estimate your CRAP Load (we've beaten this one to death - ed.), in which it gives an indication of how many tests you will need to write to reduce the CRAP index to less than an arbitrary bar of 30.

Update: tried it out, and it seems interesting - I can understand the concepts immediately and it has an amusing toilet paper icon on the menu. Here's a screenshot of the CRAP Report that it produces.

crappy.png

In the case of this anonymous component, you can see that the crapometer weighs in at 14.91% - an artitrary figure that tells me that a little over one in seven of the methods in the component are, well, crappy.

crapload.png

The CRAP Load figure above hints that maybe about 14 tests would do the trick in reducing the CRAP figure of a complex method with 0% coverage.

TrackBack

TrackBack URL for this entry:
http://blogs.iona.com/cgi-bin/mt/mt-tb.cgi/535

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on October 9, 2007 8:19 AM.

The previous post in this blog was RESTafarianism and EMF.

The next post in this blog is Some things I learned at the Eclipse Summit Europe 2007.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31