db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Embretsen <John.Embret...@Sun.COM>
Subject Testing C.R.A.P. in Derby
Date Fri, 02 Nov 2007 14:46:01 GMT
Did you know there is a new tool in town that can detect CRAPpy Java code?
Are you interested in knowing more about Derby's code quality? Test coverage?
Code complexity?

Well, I don't know if crap4j will help you much, but I just couldn't resist
trying it against the Derby code base...

C.R.A.P. = "Change Risk Analyzer and Predictor", and is a "tool to help you
defend yourself against overly complex and untested code".

The current formula for calculating CRAP is described at
http://www.artima.com/weblogs/viewpost.jsp?thread=215899 . In short, CRAP
measures the code complexity in your methods and runs your JUnit tests to
measure the test coverage of those methods. Test coverage can weigh up for code
complexity, which means that complex methods with no test coverage get a high
CRAP number.

crap4j is an open source Java implementation of such a tool, and there's a
prototype available at http://www.crap4j.org. It is available as an Ant task or
an Eclipse plugin. I did a quick run of the Ant task using the attached
modifications to build.xml (your mileage may vary).

The result was:
----------------

Percentage of CRAPpy Methods            5.80 %
CRAP Load                               23101
Total Method Count                      29300
CRAPpy Method Count (CRAP > 30 )        1698


This crap4j run measured 5.80 % CRAPpy methods in Derby (trunk @ revision
589902), which is just above the CRAP threshold of 5 %. Not bad ;) The HTML
reports include listings of methods sorted by CRAP, CRAP load, complexity and
coverage, but the files are quite big so I did not attach detailed results here.

Please note that this was just an experimental run of crap4j, which (for
example) assumed that all classes ending with "Test" in the classes/ directory
were Junit tests (which is not entirely true).

I'm just posting this in case others find this interesting and want to try it
out. And because it's a Friday, a suitable day for viewing things from a
slightly different perspective than usual.


-- 
John




Mime
View raw message