diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLink.java b/core/src/main/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLink.java index 5add75169a6..4fdb0815afc 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLink.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLink.java @@ -39,8 +39,8 @@ /** Matches misuse of link tags within throws tags. */ @BugPattern( summary = - "Javadoc links to exceptions in @throws without a @link tag (@throws Exception, not" - + " @throws {@link Exception}).", + "Don't use {@link} or {@code} in @throws tags; mention the exception name directly (e.g.," + + " @throws IOException, not @throws {@link IOException}).", severity = WARNING, tags = StandardTags.STYLE, documentSuppression = false) @@ -79,5 +79,5 @@ public Void visitErroneous(ErroneousTree node, Void unused) { } } - private static final Pattern THROWS_LINK = Pattern.compile("^@throws \\{@link ([^}]+)}"); + private static final Pattern THROWS_LINK = Pattern.compile("^@throws \\{@(?:link|code) ([^}]+)}"); } diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLinkTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLinkTest.java index babf8844d4c..12a63e3278a 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLinkTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/javadoc/InvalidThrowsLinkTest.java @@ -40,6 +40,7 @@ public void positive() { interface Test { /** * @throws {@link IOException} when failed + * @throws {@code IllegalArgumentException} if a < 0 */ void foo(int a, int b) throws IOException; } @@ -52,6 +53,7 @@ interface Test { interface Test { /** * @throws IOException when failed + * @throws IllegalArgumentException if a < 0 */ void foo(int a, int b) throws IOException; }