Skip to content

Commit eabc928

Browse files
authored
Merge pull request #1324 from vl4ds4m/bugfix-1318
Fix MultilineJavadocTagsCheck failing on block comments
2 parents bc26c5b + 10d8e2f commit eabc928

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

qulice-checkstyle/src/main/java/com/qulice/checkstyle/MultilineJavadocTagsCheck.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ private void checkJavaDoc(final String[] lines, final int start,
113113
* @return Line number with found starting comment or -1 otherwise.
114114
*/
115115
private static int findCommentStart(final String[] lines, final int start) {
116-
return MultilineJavadocTagsCheck.findTrimmedTextUp(lines, start, "/**");
116+
final int doc = MultilineJavadocTagsCheck.findTrimmedTextUp(lines, start, "/**");
117+
final int comment = MultilineJavadocTagsCheck.findTrimmedTextUp(lines, start, "/*");
118+
return Math.max(doc, comment);
117119
}
118120

119121
/**

qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,17 @@ void allowsStringLiteralsOnBothSideInComparisons()
723723
this.runValidation("ValidLiteralComparisonCheck.java", true);
724724
}
725725

726+
/**
727+
* {@link MultilineJavadocTagsCheck} mustn't throw an internal exception,
728+
* if it meets a block comment instead of javadoc.
729+
* @throws Exception If an internal exception occurs
730+
*/
731+
@Test
732+
void rejectsInvalidMethodDocWithoutInternalException()
733+
throws Exception {
734+
this.runValidation("InvalidMethodDoc.java", false);
735+
}
736+
726737
/**
727738
* Convert file name to URL.
728739
* @param file The file
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Hello
3+
*/
4+
package foo;
5+
6+
/**
7+
* The {@code InvalidMethodDoc#method} comment isn't javadoc, but it's not a reason
8+
* to fail {@code MultilineJavadocTagsCheck} validation with an unhandled exception.
9+
* @foo bar
10+
*/
11+
class InvalidMethodDoc {
12+
/*
13+
* Run method.
14+
*/
15+
void method() {
16+
}
17+
}

0 commit comments

Comments
 (0)