Search in sources :

Example 1 with DataPoint

use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.

the class ExcessiveLengthRule method visit.

@Override
public Object visit(JavaNode node, Object data) {
    if (nodeClass.isInstance(node)) {
        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);
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint)

Example 2 with DataPoint

use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.

the class AbstractNcssCountRule method visit.

@Override
public Object visit(PLSQLNode node, Object data) {
    int numNodes = 0;
    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
        PLSQLNode n = (PLSQLNode) node.jjtGetChild(i);
        Integer treeSize = (Integer) n.jjtAccept(this, data);
        numNodes += treeSize.intValue();
    }
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("Checking candidate " + node.getClass().getCanonicalName() + " against target class " + nodeClass.getCanonicalName() + " with " + numNodes + " nodes");
    }
    if (this.nodeClass.isInstance(node)) {
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("Matched candidate " + node.getClass().getCanonicalName() + " against target class " + nodeClass.getCanonicalName());
        }
        // 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);
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("Running score is " + point.getScore());
        }
    }
    return Integer.valueOf(numNodes);
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint) PLSQLNode(net.sourceforge.pmd.lang.plsql.ast.PLSQLNode) DataPoint(net.sourceforge.pmd.stat.DataPoint)

Example 3 with DataPoint

use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.

the class NcssObjectCountRule method visit.

/**
 * Override super.visit(PLSQLNode, Object) for ASTProgramUnit nodes, only
 * adding DataPoints for Schema-level Functions and Procedures
 */
@Override
public Object visit(ASTProgramUnit node, Object data) {
    int numNodes = 0;
    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
        PLSQLNode n = (PLSQLNode) node.jjtGetChild(i);
        Integer treeSize = (Integer) n.jjtAccept(this, data);
        numNodes += treeSize.intValue();
    }
    // instances should result in DataPoints
    if (node instanceof OracleObject && node.jjtGetParent() instanceof ASTGlobal) {
        // 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);
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("Running score is " + point.getScore());
        }
    }
    return Integer.valueOf(numNodes);
}
Also used : OracleObject(net.sourceforge.pmd.lang.plsql.ast.OracleObject) DataPoint(net.sourceforge.pmd.stat.DataPoint) PLSQLNode(net.sourceforge.pmd.lang.plsql.ast.PLSQLNode) DataPoint(net.sourceforge.pmd.stat.DataPoint) ASTGlobal(net.sourceforge.pmd.lang.plsql.ast.ASTGlobal)

Example 4 with DataPoint

use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.

the class NPathComplexityRule method visit.

@Override
public Object visit(ASTTypeMethod node, Object data) {
    LOGGER.entering(CLASS_NAME, "visit(ASTTypeMethod)");
    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(ASTTypeMethod)", npath);
    return Integer.valueOf(npath);
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint) DataPoint(net.sourceforge.pmd.stat.DataPoint)

Example 5 with DataPoint

use of net.sourceforge.pmd.stat.DataPoint in project pmd by pmd.

the class NPathComplexityRule method visit.

@Override
public Object visit(ASTProgramUnit node, Object data) {
    LOGGER.entering(CLASS_NAME, "visit(ASTProgramUnit)");
    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(ASTProgramUnit)", npath);
    return Integer.valueOf(npath);
}
Also used : DataPoint(net.sourceforge.pmd.stat.DataPoint) 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