Search in sources :

Example 1 with OracleObject

use of net.sourceforge.pmd.lang.plsql.ast.OracleObject 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)

Aggregations

ASTGlobal (net.sourceforge.pmd.lang.plsql.ast.ASTGlobal)1 OracleObject (net.sourceforge.pmd.lang.plsql.ast.OracleObject)1 PLSQLNode (net.sourceforge.pmd.lang.plsql.ast.PLSQLNode)1 DataPoint (net.sourceforge.pmd.stat.DataPoint)1