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
>
<
configuration
>
<
methodContexts
>
<
simple_method
>((.* )?public .*(get|set|is)[A-Z0-9].*</
simple_method
>
>
</
methodContexts
>
</
configuration
>
<
configuration
>
...
<
contextFilters
>
simple_method</
contextFilters
>
</
configuration
>
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.