Many in one: Ignoring certain methods from coverage calculation; listing risky classes/methods; instrument on the fly; bug fix for zero-complexity bug
This is my patch for my requested features at: https://sourceforge.net/tracker/index.php?func=detail&aid=2353057&group_id=130558&atid=720018
I attach here both SVN diff (patch) and the jar file with Maven POM. I name this version is
- Cobertura: 1.9-SNAPSHOT-2 (meaning the patch based on version 1.9)
- cobertura-maven-plugin: 2.2-SNAPSHOT-2
- cobertura-runtime: 1.9-SNAPHSHOT-2
Why it's SNAPHSHOT-2? I made SNAPHSHOT-1 just for ignored methods (not released). And now, SNAPHSHOT-2 include everything :-)
There are screenshot so that you can preview what's new.
1. Bug fix for zero-complexity bug
In addition to the bug fix, I change the average complexity to accumulated complexity
2. Ignoring certain methods from coverage calculation
New configuration
+ Commanline
--ignoreMethod class_name#method_name#method_descriptor
+ Maven
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2-SNAPHSHOT-2</version>
<configuration>
<instrumentation>
<ignoreMethods>
<ignoreMethod>com.*.LocaleServiceImpl#getCountryService</ignoreMethod>
<ignoreMethod>com.*.LocaleServiceImpl#getLanguageService</ignoreMethod>
</ignoreMethods>
</instrumentation>
</configuration>
</plugin>
Syntax: class_name#method_name#method_descriptor
Class name: fully qualified class. Ex: x.y.z.DummyServiceImpl
Method name: name (only name) of the method. For example: doSomething
Method descriptor: method arguments types and return type. Using bytecode representation syntax (see http://www-128.ibm.com/developerworks/java/library/j-cwt02076.html\) For example: if a method receives a String and returns an x.y.z.DummyObject, the expression is: (Ljava/lang/String;)Lx/y/z/DummyObject;
Method descriptor is only useful in case you have overloading methods. Otherwise, it can be omitted
Wildcards (not regular expression. For it's easier for all people to use wildcard instead of regular expression) can be used in both 3 parts. The following wildcards are supported:
* Any zero or more characters
? A single character
3. Listing risky classes/methods
==================================
4. On-the-fly instrumentation
Not yet complete :-( I will post it latter (it will be in a separate JAR, no modification on Cobertura is needed)
File Added: cobertura-patch.zip
SVN diff (source codes)
File Added: dashboard.PNG
Screenshot: what is shown in the dashboard now
Screenshot: how ignored methods are shown
File Added: ignored-methods.PNG
Cobertura JAR with Maven POM
File Added: cobertura-maven.zip
File Added: cobertura-maven-plugin.zip
corresponding cobertura-maven-plugin
Corresponding cobertura-runtime
File Added: cobertura-runtime.zip
Thanks for the patch! It looks like great work. I have applied the Complexity fix first. Revision 552.