Skip to content

Commit 3db9e8c

Browse files
klueverError Prone Team
authored andcommitted
Make InvalidThrowsLink catch {@code FooException} as well.
PiperOrigin-RevId: 850420159
1 parent 197c3d6 commit 3db9e8c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
/** Matches misuse of link tags within throws tags. */
4040
@BugPattern(
4141
summary =
42-
"Javadoc links to exceptions in @throws without a @link tag (@throws Exception, not"
43-
+ " @throws {@link Exception}).",
42+
"Don't use {@link} or {@code} in @throws tags; mention the exception name directly (e.g.,"
43+
+ " @throws IOException, not @throws {@link IOException}).",
4444
severity = WARNING,
4545
tags = StandardTags.STYLE,
4646
documentSuppression = false)
@@ -79,5 +79,5 @@ public Void visitErroneous(ErroneousTree node, Void unused) {
7979
}
8080
}
8181

82-
private static final Pattern THROWS_LINK = Pattern.compile("^@throws \\{@link ([^}]+)}");
82+
private static final Pattern THROWS_LINK = Pattern.compile("^@throws \\{@(?:link|code) ([^}]+)}");
8383
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void positive() {
4040
interface Test {
4141
/**
4242
* @throws {@link IOException} when failed
43+
* @throws {@code IllegalArgumentException} if a < 0
4344
*/
4445
void foo(int a, int b) throws IOException;
4546
}
@@ -52,6 +53,7 @@ interface Test {
5253
interface Test {
5354
/**
5455
* @throws IOException when failed
56+
* @throws IllegalArgumentException if a < 0
5557
*/
5658
void foo(int a, int b) throws IOException;
5759
}

0 commit comments

Comments
 (0)