Is it possible to exlude methods from coverage metrics based on complexity? (maven)

There are a large number of bean classes in a project that I'm working on, (in the 100s), and I'd like to be able to exclude the simple property methods from code coverage metrics. I had been excluding all bean classes at first, then switched to excluding property methods.

The problem with both of these is that some of the beans have at least a small amount of logic in the getter and setter methods; these I feel should be considered for code coverage metrics.

Ideally, I would be able to exclude any methods that are < 3 lines and have a complexity of 1, but I've been unable to find a way to do this in Clover for Maven.

1 answer

0 vote

Hi Nick,

You can exclude certain methods based on their number of statements or complexity, but only using Clover-for-Ant - see the <clover-setup> / <methodContext> element, the 'statements' / 'aggregatedStatements' / 'complexity' / 'aggregatedComplexity' attributes.

In case of Clover-for-Maven, the configuration option is simplified and you can define only method's name using a regular expression. There is an improvement request raised to add statements and complexity attributes:

https://jira.atlassian.com/browse/CLOV-1173

and it's scheduled for Clover 4.1.1 at the moment (end of 2015 probably); but feel free to contribute if you need this urgently - sources are on https://bitbucket.org/atlassian/maven-clover2-plugin/.

 

Cheers
Marek

Thanks Marek - it's not really urgent, just trying to convince my team of the value of these metrics, and figure the more accurate they are the easier that will be. I may take a look at the source - thanks for the link.

I case you'd decide to check sources - it's in com.atlassian.maven.plugin.clover.internal.AbstractCloverInstrumentMojo. Cheers!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

175 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you