|
|
@@ -0,0 +1,44 @@
|
|
|
+/*
|
|
|
+ * To change this license header, choose License Headers in Project Properties.
|
|
|
+ * To change this template file, choose Tools | Templates
|
|
|
+ * and open the template in the editor.
|
|
|
+ */
|
|
|
+package net.ranides.assira.rules;
|
|
|
+
|
|
|
+import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
|
|
+import net.sourceforge.pmd.lang.java.ast.JavaNode;
|
|
|
+import net.sourceforge.pmd.lang.java.rule.AbstractStatisticalJavaRule;
|
|
|
+import net.sourceforge.pmd.lang.java.rule.codesize.ExcessiveClassLengthRule;
|
|
|
+import net.sourceforge.pmd.lang.java.rule.design.ExcessiveLengthRule;
|
|
|
+import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.MINIMUM_DESCRIPTOR;
|
|
|
+import net.sourceforge.pmd.stat.DataPoint;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author msieron
|
|
|
+ */
|
|
|
+public class ClassSize extends AbstractStatisticalJavaRule {
|
|
|
+
|
|
|
+
|
|
|
+ private final Class<?> nodeClass;
|
|
|
+
|
|
|
+ public ClassSize() {
|
|
|
+ super();
|
|
|
+ this.nodeClass = ASTClassOrInterfaceDeclaration.class;
|
|
|
+ setProperty(MINIMUM_DESCRIPTOR, 1000d);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object visit(final JavaNode node, final Object data) {
|
|
|
+ if (nodeClass.isInstance(node)) {
|
|
|
+ final DataPoint point = new DataPoint();
|
|
|
+ point.setNode(node);
|
|
|
+ point.setScore(1.0 * (node.getEndLine() - node.getBeginLine()));
|
|
|
+ point.setMessage(getMessage());
|
|
|
+ addDataPoint(point);
|
|
|
+ }
|
|
|
+
|
|
|
+ return node.childrenAccept(this, data);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|