How to define maxComplexity for methodContexts in maven clover plugin configuration

Hi,

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"/>
</clover-setup>
But It seems the same configuration can not be defined with maven clover plug-in. In maven plug-in only regexp can be defined.
Example:
<configuration>
<methodContexts>
<simple_method>((.* )?public .*(get|set|is)[A-Z0-9].*</simple_method>>
</methodContexts>
</configuration>
<configuration>
...
<contextFilters>simple_method</contextFilters>
</configuration>
Are there any ways/workarounds to define maxComplexity as one of criteria for filtered code?

2 answers

0 vote

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.

See:

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

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

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 https://confluence.atlassian.com/display/CLOVER/Using+Coverage+Contexts

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Asked 2 hours ago in Confluence

What are the resources that you use to learn more about Atlassian Products?

I am gathering information about resources available for Atlassian product knowledge transferring for a presentation in our local Atlassian User Group. I want to group them in four categories From ...

23 views 1 3
View question

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