use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.
the class NPathComplexityRule method visit.
@Override
public Object visit(ASTTriggerTimingPointSection node, Object data) {
LOGGER.entering(CLASS_NAME, "visit(ASTTriggerTimingPointSection)");
int npath = complexityMultipleOf(node, 1, data);
DataPoint point = new DataPoint();
point.setNode(node);
point.setScore(1.0 * npath);
point.setMessage(getMessage());
addDataPoint(point);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("NPath complexity: " + npath + " for line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
LOGGER.exiting(CLASS_NAME, "visit(ASTTriggerTimingPointSection)", npath);
return Integer.valueOf(npath);
}
use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.
the class StatisticalRuleHelper method applyTopScore.
private SortedSet<DataPoint> applyTopScore(SortedSet<DataPoint> points, int topScore) {
SortedSet<DataPoint> s = new TreeSet<>();
DataPoint[] arr = points.toArray(new DataPoint[] {});
for (int i = arr.length - 1; i >= (arr.length - topScore); i--) {
s.add(arr[i]);
}
return s;
}
use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.
the class StatisticalRuleHelper method applyMinimumValue.
private SortedSet<DataPoint> applyMinimumValue(SortedSet<DataPoint> pointSet, double minValue) {
SortedSet<DataPoint> rc = new TreeSet<>();
double threshold = minValue - DELTA;
for (DataPoint point : pointSet) {
if (point.getScore() > threshold) {
rc.add(point);
}
}
return rc;
}
use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.
the class AbstractNcssCountRule method visit.
@Override
public Object visit(JavaNode node, Object data) {
int numNodes = 0;
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
JavaNode n = (JavaNode) node.jjtGetChild(i);
Integer treeSize = (Integer) n.jjtAccept(this, data);
numNodes += treeSize.intValue();
}
if (this.nodeClass.isInstance(node)) {
// Add 1 to account for base node
numNodes++;
DataPoint point = new DataPoint();
point.setNode(node);
point.setScore(1.0 * numNodes);
point.setMessage(getMessage());
addDataPoint(point);
}
return Integer.valueOf(numNodes);
}
use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.
the class StatisticalRuleHelper method getStdDev.
private double getStdDev() {
if (dataPoints.size() < 2) {
return Double.NaN;
}
double mean = getMean();
double deltaSq = 0.0;
double scoreMinusMean;
for (DataPoint point : dataPoints) {
scoreMinusMean = point.getScore() - mean;
deltaSq += scoreMinusMean * scoreMinusMean;
}
return Math.sqrt(deltaSq / (dataPoints.size() - 1));
}
Aggregations