Skip to content

Commit

Permalink
Issue #464: Resolve code style problems: javadoc, return statements, …
Browse files Browse the repository at this point in the history
…trailing comments
  • Loading branch information
kariem committed Oct 17, 2018
1 parent 26d7bf9 commit bc2730a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,30 @@ public void visitToken(DetailAST enumDef) {
}
}

/**
* Check whether there is an illegal token after the last comma token.
*
* @param lastComma the AST containing the last comma
* @param nextAst the next AST
* @return {@code true} if there is an illegal token after the last comma,
* {@code false otherwise}
*/
private boolean isIllegalTokenAfterComma(DetailAST lastComma, DetailAST nextAst) {
boolean illegalToken = false;

final int nextAstType = nextAst.getType();

if (nextAstType == TokenTypes.SEMI) {
if (nextAst.getLineNo() == lastComma.getLineNo()) {
// semi on the same line as last comma
return true;
illegalToken = true;
}
}
// next enum constant on the same line after comma
return nextAstType == TokenTypes.ENUM_CONSTANT_DEF;
else if (nextAstType == TokenTypes.ENUM_CONSTANT_DEF) {
// next enum constant on the same line after comma
illegalToken = true;
}
return illegalToken;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class CheckstyleRegressionTest {
/** List of checks to suppress if we dynamically add it to the configuration. */
private static final List<String> ADD_CHECK_SUPPRESSIONS = Arrays
.asList(
"EnumTrailingCommaCheck", // conflicting with NoWhitespaceBefore, SeparatorWrap
// conflicting with NoWhitespaceBefore, SeparatorWrap
"EnumTrailingCommaCheck",

"ReturnCountExtendedCheck"
);

Expand Down

0 comments on commit bc2730a

Please sign in to comment.