/** * Class level comment. */ public class Foo { /** the bar counter. */ public int bar; /** the test enum. */ public enum Enum {} /** * This is the comment for the constructor */ public Foo() {} /** * This is the comment for the first method */ public void doNothing() {} /** * This is the comment for the second method */ public void doSomething() {} }
public class Foo { public int bar; public enum Enum {} public Foo() {} public void doNothing() {} public void doSomething() {} }
Missing comments - all required (default).
6
All elements have javadoc comments.
0
Missing comments - only class level required.
Required
Ignored
Ignored
Ignored
Ignored
1
Too many comments - all comments are unwanted.
Unwanted
Unwanted
Unwanted
Unwanted
Unwanted
6
#1115 commentRequiredRule in pmd 5.1 is not working properly
2
/** * Test class */ public class Test { public void method1() { /** * comment here */ }

public void method2() { } }
#1115 commentRequiredRule in pmd 5.1 is not working properly - without new lines
2
/** Test class */ public class Test { public void method1() { /** comment here */ } public void method2() { } }
#1289 CommentRequired not ignored if javadoc {@inheritDoc} anon inner classes
0
/** * Comment required test class. */ public class CommentRequired { /** * Creates a new instance of comment required. */ public CommentRequired() { Object o = new Object() { /** * {@inheritDoc} */ public String toString() { return "Inner Class"; } }; } }
#1434 CommentRequired raises violation on serialVersionUID field
0
/** The class comment */ public class CommentRequired implements Serializable { private static final long serialVersionUID = 42L; }
comment required on serialVersionUID of wrong type
1
3
/** The class comment */ public class CommentRequired implements Serializable { private static final int serialVersionUID = 42L; }
serialVersionUID comment required
Required
1
3
/** The class comment */ public class CommentRequired implements Serializable { private static final long serialVersionUID = 42L; }
#1522 [java] CommentRequired: false positive
0
package de.konsens.biene.ka.client;

/** * Kommentar zu PmdMissingHeaderCommentTest */ public class PmdMissingHeaderCommentTest {

/** * Kommentar zu methode1() */ public void methode1() {

/** * Kommentar zu Local */ class Local {

/** * Kommentar zu methode1() */ void methode1() {

}

}

Local local = new Local();

local.methode1();

/** * Kommentar zu Local2 */ class Local2 {

/** * Kommentar zu methode1() */ void methode1() {

} }

Local2 local2 = new Local2(); local2.methode1();

} }
Comment required ignores @override methods by default
0
/** * Comment required test class. */ public class CommentRequired { @Override public void noComment() { Object o = new Object() {

@Override public String toString() { return "Inner Class"; } }; } }
Test @override methods reporting
Required
2
/** * Comment required test class. */ public class CommentRequired { @Override public void noComment() { Object o = new Object() {

@Override public String toString() { return "Inner Class"; } }; } }
Test @override methods reporting #2
Required
0
/** * Comment required test class. */ public class CommentRequired { /** * Comment provided */ @Override public void noComment() { Object o = new Object() {

/** * @inheritDoc */ @Override public String toString() { return "Inner Class"; } }; } }
Test @override methods unwanted
Unwanted
2
/** * Comment required test class. */ public class CommentRequired { /** * Comment provided */ @Override public void noComment() { Object o = new Object() {

/** * @inheritDoc */ @Override public String toString() { return "Inner Class"; } }; } }
Test getter or setter comments are ignored by default
Ignored
0
/** * Comment required test class. */ public class CommentRequired {

private int foo;

public int getFoo() { Object o = new Object() {

String foox;

public String getFoox() { return foox; } }; return foo; }

public void setFoo(int x) { foo = x; }

}
Test accessors are reported when required
Ignored
Required
3
/** * Comment required test class. */ public class CommentRequired {

private int foo;

public int getFoo() { Object o = new Object() {

String foox;

public String getFoox() { return foox; } }; return foo; }

public void setFoo(int x) { foo = x; }

}
Test accessors are reported when unwanted
Ignored
Unwanted
2
/** * Comment required test class. */ public class CommentRequired {

private int foo;

/** * @return foo */ public int getFoo() { Object o = new Object() {

String foox; /** * @return foox */ public String getFoox() { return foox; } }; return foo; }

public void setFoo(int x) { foo = x; }

}