diff --git a/.ci/files/all-java.xml b/.ci/files/all-java.xml
index 5eb0304f47..1a4510cd06 100644
--- a/.ci/files/all-java.xml
+++ b/.ci/files/all-java.xml
@@ -155,8 +155,8 @@
-
-
+
+
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/TooManyFieldsRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/TooManyFieldsRule.java
deleted file mode 100644
index 10f1ccbbe1..0000000000
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/TooManyFieldsRule.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
- */
-
-package net.sourceforge.pmd.lang.java.rule.design;
-
-import static net.sourceforge.pmd.properties.constraints.NumericConstraints.positive;
-
-import java.util.List;
-
-import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
-import net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration;
-import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
-import net.sourceforge.pmd.properties.PropertyDescriptor;
-import net.sourceforge.pmd.properties.PropertyFactory;
-
-
-public class TooManyFieldsRule extends AbstractJavaRule {
-
- private static final int DEFAULT_MAXFIELDS = 15;
-
- private static final PropertyDescriptor MAX_FIELDS_DESCRIPTOR
- = PropertyFactory.intProperty("maxfields")
- .desc("Max allowable fields")
- .defaultValue(DEFAULT_MAXFIELDS)
- .require(positive())
- .build();
-
- public TooManyFieldsRule() {
- definePropertyDescriptor(MAX_FIELDS_DESCRIPTOR);
- addRuleChainVisit(ASTClassOrInterfaceDeclaration.class);
- }
-
- @Override
- public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
- final int maxFields = getProperty(MAX_FIELDS_DESCRIPTOR);
- int counter = 0;
-
- final List l = node.findDescendantsOfType(ASTFieldDeclaration.class);
-
- for (ASTFieldDeclaration fd : l) {
- if (fd.isFinal() && fd.isStatic()) {
- continue;
- }
- counter++;
- }
-
- if (counter > maxFields) {
- addViolation(data, node);
- }
-
- return data;
- }
-}
diff --git a/pmd-java/src/main/resources/category/java/design.xml b/pmd-java/src/main/resources/category/java/design.xml
index ef526f1480..c22f7b8fac 100644
--- a/pmd-java/src/main/resources/category/java/design.xml
+++ b/pmd-java/src/main/resources/category/java/design.xml
@@ -1296,7 +1296,7 @@ public class Foo {
language="java"
since="3.0"
message="Too many fields"
- class="net.sourceforge.pmd.lang.java.rule.design.TooManyFieldsRule"
+ class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#toomanyfields">
Classes that have too many fields can become unwieldy and could be redesigned to have fewer fields,
@@ -1304,6 +1304,20 @@ possibly through grouping related fields in new objects. For example, a class w
city/state/zip fields could park them within a single Address field.
3
+
+
+
+
+ $maxfields]
+]]>
+
+
+
-
3 fields, reduced max to 2
2
1
+ 1
16 fields, bad
1
+ 1
2 inner classes, each with > 10 fields
2
+ 2,20