1 4 package net.sourceforge.pmd.rules.design; 5 6 import net.sourceforge.pmd.ast.SimpleJavaNode; 7 import net.sourceforge.pmd.stat.DataPoint; 8 import net.sourceforge.pmd.stat.StatisticalRule; 9 10 20 public class ExcessiveLengthRule extends StatisticalRule { 21 private Class nodeClass; 22 23 public ExcessiveLengthRule(Class nodeClass) { 24 this.nodeClass = nodeClass; 25 } 26 27 public Object visit(SimpleJavaNode node, Object data) { 28 if (nodeClass.isInstance(node)) { 29 DataPoint point = new DataPoint(); 30 point.setNode(node); 31 point.setScore(1.0 * (node.getEndLine() - node.getBeginLine())); 32 point.setMessage(getMessage()); 33 addDataPoint(point); 34 } 35 36 return node.childrenAccept(this, data); 37 } 38 } 39 40 41 | Popular Tags |