Skip to content

Commit 5ef437d

Browse files
cushonError Prone Team
authored andcommitted
Disable MissingJavadoc on constructors
PiperOrigin-RevId: 940668225
1 parent f824f90 commit 5ef437d

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

core/src/main/java/com/google/errorprone/bugpatterns/javadoc/MissingJavadoc.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public Description matchMethod(MethodTree methodTree, VisitorState state) {
7272
if (symbol == null) {
7373
return NO_MATCH;
7474
}
75+
if (symbol.isConstructor()) {
76+
// Constructors have a better than average change of being "self-explanatory":
77+
// https://google.github.io/styleguide/javaguide.html#s7.3.1-javadoc-exception-self-explanatory
78+
return NO_MATCH;
79+
}
7580
if (!findSuperMethods(symbol, state.getTypes()).isEmpty()) {
7681
return NO_MATCH;
7782
}

core/src/test/java/com/google/errorprone/bugpatterns/javadoc/MissingJavadocTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,18 @@ private static final class Builder {}
171171
""")
172172
.doTest();
173173
}
174+
175+
@Test
176+
public void publicConstructorWithoutJavadoc_passes() {
177+
compilationHelper
178+
.addSourceLines(
179+
"Test.java",
180+
"""
181+
/** This is class doc. */
182+
public class Test {
183+
public Test() {}
184+
}
185+
""")
186+
.doTest();
187+
}
174188
}

0 commit comments

Comments
 (0)