How do I configure PMD to ignore missing constructor tests

I often have my students submit 100% static methods for testing.  How can I get PMD to ignore that they haven't tested the default constructor?

It keeps knocking off points saying that the class declaration has not been tested.

You can see in the example below, that all methods are static:

 

public class Silly // it sayd that this line of code was never tested... but how to you ignore it?

{

  public static int add(int a, int b)

  {

    return a + b;

  }

}
 

Groups:

Comments

Jeremy W

http://pmd.sourceforge.net/pm

http://pmd.sourceforge.net/pmd-4.3/rules/controversial.html

I think what I want is this.  How do I add this to the PMD ruleset in webcat?

UnnecessaryConstructor

Since: PMD 1.0

This rule detects when a constructor is not necessary; i.e., when there's only one constructor, it's public, has an empty body, and takes no arguments.

This rule is defined by the following XPath expression:

                    
//ClassOrInterfaceBody[count(ClassOrInterfaceBodyDeclaration/ConstructorDeclaration)=1]
/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration
[@Public='true']
[not(FormalParameters/*)]
[not(BlockStatement)]
[not(NameList)]
[count(ExplicitConstructorInvocation/Arguments/ArgumentList/Expression)=0]