From be8be03107a778e9d91c70341a29fc7c5c21a356 Mon Sep 17 00:00:00 2001 From: Kariem Hussein Date: Sun, 21 Oct 2018 13:26:12 +0200 Subject: [PATCH] Issue #464: Simplify check for illegal token --- .../checks/coding/EnumTrailingCommaCheck.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/EnumTrailingCommaCheck.java b/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/EnumTrailingCommaCheck.java index 83e1b4b90..f05372aa7 100644 --- a/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/EnumTrailingCommaCheck.java +++ b/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/EnumTrailingCommaCheck.java @@ -140,21 +140,11 @@ public void visitToken(DetailAST enumDef) { * {@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 - illegalToken = true; - } - } - else if (nextAstType == TokenTypes.ENUM_CONSTANT_DEF) { - // next enum constant on the same line after comma - illegalToken = true; - } - return illegalToken; + // semi on the same line as last comma, or followed by enum constant + return (nextAstType == TokenTypes.SEMI && nextAst.getLineNo() == lastComma.getLineNo()) + || nextAstType == TokenTypes.ENUM_CONSTANT_DEF; } /**