diff --git a/pmd-java/src/main/resources/rulesets/java/design.xml b/pmd-java/src/main/resources/rulesets/java/design.xml index 681cd2407d..4035beeddb 100644 --- a/pmd-java/src/main/resources/rulesets/java/design.xml +++ b/pmd-java/src/main/resources/rulesets/java/design.xml @@ -1805,10 +1805,16 @@ Fields should be declared at the top of the class, before any method declaration 0] +[not(.//ClassOrInterfaceBodyDeclaration) or $ignoreAnonymousClassDeclarations = 'false'] +[../preceding-sibling::ClassOrInterfaceBodyDeclaration + [ + count(child::*) + - count(FieldDeclaration) + - count(Annotation) + - count(EnumDeclaration[$ignoreEnumDeclarations = 'true']) + > 0 + ] +] ]]>