I am using PMD plugin in my Java Project.
When I run the PMD it shows the warning as "Document Empty Constructor ".
My code is as follows...
public class ExceptionHandlerImpl implements ExceptionHandler {
private static final Logger log = Logger
.getLogger(ExceptionHandlerImpl.class);
/**
* Default Constructor
*/
public ExceptionHandlerImpl()
{
super();
}
On the above constructor code it is showing "Document Empty Constructor".
How do I resolve this and why this is occurring?
In your case the UncommentedEmptyConstructor rule is triggered.
It finds places where non-private constructor does not contain any statements or it contains just super()
and there is no comment inside. The Javadoc before is not relevant for this rule.
By providing comments in empty constructors it is easier to distinguish between intentional (for example to be able to provide Javadoc) and unintentional empty constructors (someone forgot to write the implementation or this constructor can be just removed).
This rule expects from you something like that:
class MyConstructorIsNeededHere {
/**
* Creates instance of {@link Foo}.
*/
MyConstructorIsNeededHere() {
// The explicit constructor is here, so that it is possible to provide Javadoc.
}
}
and warns you in the following case:
class OhNoICanBeRemoved {
OhNoICanBeRemoved() {
super();
}
}