Issue #2387: Do not recognize '/**/' as valid Javadoc

This commit is contained in:
Michal Kordas 2015-10-31 16:17:24 +01:00 committed by Roman Ivanov
parent 30881d8524
commit 16493bfb50
4 changed files with 19 additions and 3 deletions

View File

@ -150,7 +150,8 @@ public final class FileContents implements CommentListener {
}
// Remember if possible Javadoc comment
if (line(startLineNo - 1).indexOf("/**", startColNo) != -1) {
final String firstLine = line(startLineNo - 1);
if (firstLine.contains("/**") && !firstLine.contains("/**/")) {
javadocComments.put(endLineNo - 1, comment);
}
}

View File

@ -333,7 +333,9 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport {
"105:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"106:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"107:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"108:9: " + getCheckMessage(MSG_JAVADOC_MISSING), };
"108:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"119:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputNoJavadoc.java"), expected);
}
@ -376,7 +378,9 @@ public class JavadocMethodCheckTest extends BaseCheckTestSupport {
"96:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"105:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"107:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"108:9: " + getCheckMessage(MSG_JAVADOC_MISSING), };
"108:9: " + getCheckMessage(MSG_JAVADOC_MISSING),
"119:5: " + getCheckMessage(MSG_JAVADOC_MISSING),
};
verify(checkConfig, getPath("InputNoJavadoc.java"), expected);
}

View File

@ -205,6 +205,14 @@ public class JavadocStyleCheckTest
verify(checkConfig, getPath("InputJavadocStyleHtmlComment.java"), expected);
}
@Test
public void testOnInputWithNoJavadoc() throws Exception {
final DefaultConfiguration checkConfig = createCheckConfig(JavadocStyleCheck.class);
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputNoJavadoc.java"), expected);
}
@Test
public void testScopePublic()
throws Exception {

View File

@ -114,4 +114,7 @@ class PackageClass {
// no warning, 'serialVersionUID' fields do not require Javadoc
private static final long serialVersionUID = 0;
}
/**/
void methodWithTwoStarComment() {}
}