From 172c20efa683ba81d3a215f248a7e988777c06ed Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 24 Jan 2015 15:57:04 +0100 Subject: [PATCH] Small performance improvements for rule FieldDeclarationsShouldBeAtStartOfClass It is the slowest rule from #1308 PMD runs endlessly on some generated files --- .../src/main/resources/rulesets/java/design.xml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 + ] +] ]]>