Skip to content

Commit

Permalink
Don't fire MissingSummary on _effectively_ private methods.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 487766405
  • Loading branch information
graememorgan authored and Error Prone Team committed Nov 11, 2022
1 parent 5b56e10 commit c7fcb6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public static boolean canBeRemoved(ClassSymbol symbol) {
}

/** Returns whether this symbol or any of its owners are private. */
private static boolean isEffectivelyPrivate(Symbol symbol) {
public static boolean isEffectivelyPrivate(Symbol symbol) {
return enclosingElements(symbol).anyMatch(Symbol::isPrivate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static com.google.errorprone.util.ASTHelpers.findSuperMethods;
import static com.google.errorprone.util.ASTHelpers.getSymbol;
import static com.google.errorprone.util.ASTHelpers.hasAnnotation;
import static com.google.errorprone.util.ASTHelpers.isEffectivelyPrivate;
import static java.util.stream.Collectors.joining;

import com.google.errorprone.BugPattern;
Expand Down Expand Up @@ -198,8 +199,6 @@ private static boolean requiresJavadoc(Tree tree, VisitorState state) {
&& !findSuperMethods((MethodSymbol) symbol, state.getTypes()).isEmpty()) {
return false;
}
return symbol != null
&& (symbol.getModifiers().contains(Modifier.PUBLIC)
|| symbol.getModifiers().contains(Modifier.PROTECTED));
return symbol != null && !isEffectivelyPrivate(symbol);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ public void privateCase() {
.doTest();
}

@Test
public void effectivelyPrivateCase() {
helper
.addSourceLines(
"Test.java", //
"class Test {",
" private class Inner {",
" /** @throws IllegalStateException */",
" public void test() {}",
" }",
"}")
.doTest();
}

@Test
public void negative() {
helper
Expand Down

0 comments on commit c7fcb6e

Please sign in to comment.