Skip to content

Commit f9bdee0

Browse files
committed
Make AlmostJavadoc an error
Its two findings were block comments meant as Javadoc, both in the javadoc package: - The comment above JavadocLexer.LITERAL_PATTERN, which the Javadoc of joinAdjacentLiteralsAndAdjacentWhitespace links to for the discussion, is the field's Javadoc now: its HTML samples are in {@code}, and the method it names is a link. - CharStream.tryConsumeRegex's @PARAM is in a Javadoc, with a summary.
1 parent 0030c96 commit f9bdee0

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎buildSrc/src/main/groovy/open-java-format.error-prone-conventions.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tasks.withType(JavaCompile).configureEach {
2525
nullaway {
2626
handleTestAssertionLibraries = true
2727
}
28+
error('AlmostJavadoc')
2829
error('CanonicalAnnotationSyntax')
2930
error('CollectorMutability')
3031
error('DefaultCharset')

‎open-java-format/src/main/java/com/palantir/javaformat/java/javadoc/CharStream.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ boolean tryConsume(String expected) {
4242
return true;
4343
}
4444

45-
/*
45+
/**
46+
* Like {@link #tryConsume}, but for a match of the pattern at the start of the remaining input.
47+
*
4648
* @param pattern the pattern to search for, which must be anchored to match only at position 0
4749
*/
4850
boolean tryConsumeRegex(Pattern pattern) {

‎open-java-format/src/main/java/com/palantir/javaformat/java/javadoc/JavadocLexer.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -647,15 +647,15 @@ private static boolean hasMultipleNewlines(String s) {
647647
private static final Pattern BR_PATTERN = openTagPattern("br");
648648
private static final Pattern SNIPPET_TAG_OPEN_PATTERN = compile("^[{]@snippet\\b");
649649
private static final Pattern INLINE_TAG_OPEN_PATTERN = compile("^[{]@\\w*");
650-
/*
651-
* We exclude < so that we don't swallow following HTML tags. This lets us fix up "foo<p>" (~400
652-
* hits in Google-internal code). We will join unnecessarily split "words" (like "foo<b>bar</b>")
653-
* in a later step. There's a similar story for braces. I'm not sure I actually need to exclude @
654-
* or *. TODO(cpovirk): Try removing them.
650+
/**
651+
* We exclude {@code <} so that we don't swallow following HTML tags. This lets us fix up {@code foo<p>} (~400
652+
* hits in Google-internal code). We will join unnecessarily split "words" (like {@code foo<b>bar</b>}) in a later
653+
* step. There's a similar story for braces. I'm not sure I actually need to exclude {@code @} or {@code *}.
654+
* TODO(cpovirk): Try removing them.
655655
*
656-
* Thanks to the "rejoin" step in joinAdjacentLiteralsAndAdjacentWhitespace(), we could get away
657-
* with matching only one character here. That would eliminate the need for the regex entirely.
658-
* That might be faster or slower than what we do now.
656+
* <p>Thanks to the "rejoin" step in {@link #joinAdjacentLiteralsAndAdjacentWhitespace}, we could get away with
657+
* matching only one character here. That would eliminate the need for the regex entirely. That might be faster or
658+
* slower than what we do now.
659659
*/
660660
private static final Pattern LITERAL_PATTERN = compile("^.[^ \t\n@<{}*]*", DOTALL);
661661

0 commit comments

Comments
 (0)