diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java
index 62544fc80e..604de9f33f 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java
@@ -115,15 +115,7 @@ public class CommentDefaultAccessModifierRule extends AbstractIgnoredAnnotationR
// if is a default access modifier check if there is a comment
// in this line
&& !interestingLineNumberComments.contains(decl.getBeginLine())
- // that it is not annotated with @VisibleForTesting
- && hasNoVisibleForTestingAnnotation(decl);
- }
-
- private boolean hasNoVisibleForTestingAnnotation(AbstractJavaAccessNode decl) {
- boolean result = true;
- if (hasIgnoredAnnotation(decl)) {
- result = false;
- }
- return result;
+ // that it is not annotated with e.g. @VisibleForTesting
+ && !hasIgnoredAnnotation(decl);
}
}
diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index 9a9138a4f0..616f101f4d 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -399,6 +399,8 @@ public class Éléphant {}
To avoid mistakes if we want that a Method, Constructor, Field or Nested class have a default access modifier
we must add a comment at the beginning of it's declaration.
By default the comment must be /* default */ or /* package */, if you want another, you have to provide a regular expression.
+This rule ignores by default all cases that have a @VisibleForTesting annotation. Use the
+property "ignoredAnnotations" to customize the recognized annotations.
3