Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Checks that the javadoc comments follow Spring conventions.
*
* @author Phillip Webb
* @author Venkata Naga Sai Srikanth Gollapudi
*/
public class SpringJavadocCheck extends AbstractSpringCheck {

Expand Down Expand Up @@ -153,7 +154,7 @@ private void checkTagCase(DetailAST ast, TextBlock javadoc) {
Matcher matcher = pattern.matcher(text[i]);
if (matcher.find()) {
String description = matcher.group(1).trim();
if (startsWithUppercase(description)) {
if (!hasCorrectCase(description)) {
log(javadoc.getStartLineNo() + i, text[i].length() - description.length(), "javadoc.badCase");
}
}
Expand Down Expand Up @@ -244,8 +245,23 @@ private void checkAnnotationFieldJavaDoc(DetailAST ast, TextBlock javadoc) {
}
}

private boolean hasCorrectCase(String description) {
return startsWithAcronym(description) || !startsWithUppercase(description);
}

private boolean startsWithUppercase(String description) {
return description.length() > 0 && Character.isUpperCase(description.charAt(0));
return !description.isEmpty() && Character.isUpperCase(description.charAt(0));
}

private boolean startsWithAcronym(String description) {
int i = 0;
while (i < description.length() && Character.isLetter(description.charAt(i))) {
if (!Character.isUpperCase(description.charAt(i))) {
return false;
}
i++;
}
return i >= 2;
}

private void checkForNonJavadocComments(TextBlock block) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
* @param <T> this is a valid param
* @author Phillip Webb
* @author Venkata Naga Sai Srikanth Gollapudi
*/
public class JavadocValid<T> {

Expand Down Expand Up @@ -46,6 +47,15 @@ public void test2(String something) {
public String test3(String something) throws RuntimeException {
}

/**
* Do something with acronyms.
* @param something JNI hints for the thing
* @return the thing
* @throws RuntimeException on the error
*/
public String test4(String something) throws RuntimeException {
}

/**
* Class with a numeric date since.
* @since 28.12.2003
Expand Down