#1275 False positive: UnusedModifier rule for static inner class in enum
This commit is contained in:
@ -15,10 +15,7 @@ public class UnusedModifierRule extends AbstractJavaRule {
|
||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||
if (!node.isInterface() && node.isNested() && (node.isPublic() || node.isStatic())) {
|
||||
ASTClassOrInterfaceDeclaration parentClassInterface = node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class);
|
||||
ASTEnumDeclaration parentEnum = node.getFirstParentOfType(ASTEnumDeclaration.class);
|
||||
if (parentClassInterface != null && parentClassInterface.isInterface()
|
||||
||
|
||||
parentEnum != null) {
|
||||
if (parentClassInterface != null && parentClassInterface.isInterface()) {
|
||||
addViolation(data, node, getMessage());
|
||||
}
|
||||
} else if (node.isInterface() && node.isNested() && (node.isPublic() || node.isStatic())) {
|
||||
|
@ -270,17 +270,16 @@ public enum Testing {
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>False negative: static class nested in enum</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<description>#1275 False positive: UnusedModifier rule for static inner class in enum</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public enum Testing {
|
||||
Test;
|
||||
public enum MyEnum
|
||||
{
|
||||
VALUE_1,
|
||||
VALUE_2;
|
||||
|
||||
public void test(ITesting tester) {
|
||||
tester.test();
|
||||
}
|
||||
public static class ITesting {
|
||||
public void test() {};
|
||||
private static class MyInnerClass // violation detected by PMD
|
||||
{
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
|
@ -18,3 +18,4 @@
|
||||
* [#1272](https://sourceforge.net/p/pmd/bugs/1272/): varargs in methods are causing IndexOutOfBoundException when trying to process files
|
||||
* [#1273](https://sourceforge.net/p/pmd/bugs/1273/): CheckResultSet false positive in try-with-resources nested in if
|
||||
* [#1274](https://sourceforge.net/p/pmd/bugs/1274/): ant integration broken with pmd-5.2.0
|
||||
* [#1275](https://sourceforge.net/p/pmd/bugs/1275/): False positive: UnusedModifier rule for static inner class in enum
|
||||
|
Reference in New Issue
Block a user