diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java index ce18e3325..33b21aa15 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java @@ -278,7 +278,8 @@ public class RedundantModifierCheck checkFinal = checkFinal || classModifiers.branchContains(TokenTypes.FINAL); parent = null; } - else if (parent.getType() == TokenTypes.LITERAL_NEW) { + else if (parent.getType() == TokenTypes.LITERAL_NEW + || parent.getType() == TokenTypes.ENUM_CONSTANT_DEF) { checkFinal = true; parent = null; } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java index 8bf986b9c..81590d69a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java @@ -227,7 +227,10 @@ public class RedundantModifierCheckTest @Test public void testEnumMethods() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(RedundantModifierCheck.class); - final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; + final String[] expected = { + "7:16: " + getCheckMessage(MSG_KEY, "final"), + "22:16: " + getCheckMessage(MSG_KEY, "final"), + }; verify(checkConfig, getPath("InputFinalInEnumMethods.java"), expected); } }