Skip to content

Commit

Permalink
Issue checkstyle#10806: RedundantModifierCheck fails on nested interf…
Browse files Browse the repository at this point in the history
…ace and annotation declarations
  • Loading branch information
AkMo3 authored and rnveach committed Oct 10, 2021
1 parent 84e45f7 commit 1acbabe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ private void processInterfaceOrAnnotation(DetailAST ast) {
|| type == TokenTypes.FINAL
&& ast.getType() != TokenTypes.CLASS_DEF) {
log(modifier, MSG_KEY, modifier.getText());
break;
}

modifier = modifier.getNextSibling();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,18 @@ public void testTryWithResourcesBlock() throws Exception {
expected);
}

@Test
public void testNestedDef() throws Exception {
final String[] expected = {
"10:5: " + getCheckMessage(MSG_KEY, "public"),
"11:5: " + getCheckMessage(MSG_KEY, "static"),
"12:5: " + getCheckMessage(MSG_KEY, "public"),
"12:12: " + getCheckMessage(MSG_KEY, "static"),
"13:5: " + getCheckMessage(MSG_KEY, "static"),
"13:12: " + getCheckMessage(MSG_KEY, "public"),
"16:9: " + getCheckMessage(MSG_KEY, "public"),
};
verifyWithInlineConfigParser(getPath(
"InputRedundantModifierNestedDef.java"), expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
RedundantModifier
*/

package com.puppycrawl.tools.checkstyle.checks.modifier.redundantmodifier;

public interface InputRedundantModifierNestedDef {
public enum MyInnerEnum1 {} // violation
static enum MyInnerEnum2 {} // violation
public static enum MyInnerEnum3 {} // 2 violations
static public enum MyInnerEnum4 {} // 2 violations

interface MyInnerInterface {
public strictfp class MyInnerClass {} // violation
}
}

0 comments on commit 1acbabe

Please sign in to comment.