[java] CommentDefaultAccessModifierRule

* refactor
* extend documentation
This commit is contained in:
Andreas Dangel
2018-10-27 22:53:44 +02:00
parent 741f204739
commit c4e7117f5e
2 changed files with 4 additions and 10 deletions

View File

@ -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);
}
}

View File

@ -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.
</description>
<priority>3</priority>
<example>