Skip to content

Commit

Permalink
Issue checkstyle#4556: fixed NPE in NoWhitespaceAftercCheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergileon committed Aug 30, 2017
1 parent 1862af7 commit 4f1bd87
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
Expand Up @@ -125,7 +125,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck {
private static final Pattern MATCH_JAVADOC_NOARG_CURLY =
CommonUtils.createPattern("\\{\\s*@(inheritDoc)\\s*\\}");

/** Default value of minimal amount of lines in method to allow no documentation.*/
/** Default value of minimal amount of lines in method to demand documentation presence.*/
private static final int DEFAULT_MIN_LINE_COUNT = -1;

/** The visibility scope where Javadoc comments are checked. */
Expand All @@ -134,7 +134,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck {
/** The visibility scope where Javadoc comments shouldn't be checked. */
private Scope excludeScope;

/** Minimal amount of lines in method to allow no documentation.*/
/** Minimal amount of lines in method to demand documentation presence.*/
private int minLineCount = DEFAULT_MIN_LINE_COUNT;

/**
Expand Down
Expand Up @@ -162,7 +162,13 @@ private static DetailAST getWhitespaceFollowedNode(DetailAST ast) {
whitespaceFollowedAst = getArrayDeclaratorPreviousElement(ast);
break;
case TokenTypes.INDEX_OP:
whitespaceFollowedAst = getIndexOpPreviousElement(ast);
final DetailAST resultAst = getIndexOpPreviousElement(ast);
if (resultAst == null) {
whitespaceFollowedAst = ast;
}
else {
whitespaceFollowedAst = getIndexOpPreviousElement(ast);
}
break;
default:
whitespaceFollowedAst = ast;
Expand Down
Expand Up @@ -109,6 +109,7 @@ public void testArrayDeclarations() throws Exception {
"39:24: " + getCheckMessage(MSG_KEY, "int"),
"40:16: " + getCheckMessage(MSG_KEY, "int"),
"43:63: " + getCheckMessage(MSG_KEY, "getLongMultArray"),
"47:26: " + getCheckMessage(MSG_KEY, "["),
};
verify(checkConfig, getPath("InputNoWhitespaceAfterArrayDeclarations.java"), expected);
}
Expand Down
Expand Up @@ -43,4 +43,6 @@ private String[][][] getSeveralLines() { //Correct
private long getLongMultArray(int someParam, String value) [][][] { //Incorrect
return null;
}
int aa= new int[]{1}[0];//Correct
int bb= new int[]{1}[ 0];//Incorrect
}
2 changes: 1 addition & 1 deletion src/xdocs/config_javadoc.xml
Expand Up @@ -212,7 +212,7 @@ public int checkReturnTag(final int aTagIndex,
</tr>
<tr>
<td>minLineCount</td>
<td>Minimal amount of lines in method to allow no documentation.</td>
<td>Minimal amount of lines in method to demand documentation presence.</td>
<td><a href="property_types.html#integer">Integer</a></td>
<td><code>-1</code></td>
<td>6.0</td>
Expand Down

0 comments on commit 4f1bd87

Please sign in to comment.