The cyclomatic complexity class (net.sourceforge.pmd.rules.CyclomaticComplexity) has three class members: reportLevel, showClassesComplexity, and showMethodsComplexity. The default for the show*Complexity members is true.
When (showMethodsComplexity==false) the net effect should be to show classes whose average complexity meets or exceeds the reportLevel. However, constructors are not being treated as methods, thus constructors with cyclomatic complexities equal to or greather than the reportLevel are displayed instead of just classes whose average complexity is too high.
The fix is easy, wrap the code within the visit(ASTConstructorDeclaration node, Object data) method in the same IF statement [ if ( showMethodsComplexity ) { ... } ] used within the visit(ASTMethodDeclaration node, Object data) method.
Alternatively, add a showConstructorComplexity member to the class and update the constructor visit() method to use its value.
Hi,
Could provide a patch for your fix ? It would be far more easier than trying to re implement based on your description...
Thanks !