Search in sources :

Example 6 with DataPoint

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);
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint) DataPoint(net.sourceforge.pmd.stat.DataPoint)

Example 7 with DataPoint

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;
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint) TreeSet(java.util.TreeSet) DataPoint(net.sourceforge.pmd.stat.DataPoint)

Example 8 with DataPoint

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;
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint) TreeSet(java.util.TreeSet)

Example 9 with DataPoint

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);
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint) DataPoint(net.sourceforge.pmd.stat.DataPoint) JavaNode(net.sourceforge.pmd.lang.java.ast.JavaNode)

Example 10 with DataPoint

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));
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint)

Aggregations

DataPoint (net.sourceforge.pmd.stat.DataPoint)21 TreeSet (java.util.TreeSet)2 PLSQLNode (net.sourceforge.pmd.lang.plsql.ast.PLSQLNode)2 ApexNode (net.sourceforge.pmd.lang.apex.ast.ApexNode)1 JavaNode (net.sourceforge.pmd.lang.java.ast.JavaNode)1 ASTGlobal (net.sourceforge.pmd.lang.plsql.ast.ASTGlobal)1 OracleObject (net.sourceforge.pmd.lang.plsql.ast.OracleObject)1 Metric (net.sourceforge.pmd.stat.Metric)1