How to define maxComplexity for methodContexts in maven clover plugin configuration


I want to customize clover coverage reports to exclude simple methods (setters/getters) with complexity less than 2. It's possible with Ant plug-in.

Сonfiguration example:

<clover-setup ...>
<!-- Don't instrument methods which have cyclomatic complexity <= 1 or <= 3 statements -->
<methodContext name="simple_method" regexp="(.* )?public .*(get|set|is)[A-Z0-9].*" " maxComplexity="1"/>
But It seems the same configuration can not be defined with maven clover plug-in. In maven plug-in only regexp can be defined.
<simple_method>((.* )?public .*(get|set|is)[A-Z0-9].*</simple_method>>
Are there any ways/workarounds to define maxComplexity as one of criteria for filtered code?

2 answers

0 votes

Unfortunately, maxComplexity/maxStatements are not available in Maven plugin right now (version 3.1.7). I've created CLOV-1173 improvement request for this. As a workaround you could try using the Maven Antrun Plugin and calling Clover from it.


Can we use a regex like below to eliminate Getter/Setters using methodContext in Maven ? 

<getterSetter>(?m)((?:public |private |protected )?[\w$]+) (get|set|is)([\w$]+)\(([\w$]+(?:\[\])? [\w$]+)?\) \{\s+(return [\w$]+;|this.[\w$]+ = [\w$]+;)\s+\}</getterSetter>

No. The methodContext matches method's signature (i.e. annotations + modifiers + return type + name + arguments) and not method's body.

Besides - your regexp part for method's signature is unnecessarily complex - Clover performs signature normalisation before comparison, see

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Agile

How Scrum works? It starts with training and education

To answer “How scrum works,” most of the teams I've worked with first addressed the question: “where to start?”  That question applies to both implementation and improvements on the Scrum framew...

223 views 3 7
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