/*
 *  @author Ranides Atterwim <ranides@gmail.com>
 *  @copyright Ranides Atterwim
 *  @license WTFPL
 *  @url http://ranides.net/projects/assira.rules
 */
package net.ranides.assira.rules;

import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
import net.sourceforge.pmd.lang.java.ast.JavaNode;
import net.sourceforge.pmd.lang.java.rule.AbstractStatisticalJavaRule;
import net.sourceforge.pmd.stat.DataPoint;

public class UFRule extends AbstractStatisticalJavaRule {

    private final Class<?> nodeClass;

    public UFRule() {
        super();
        this.nodeClass = ASTClassOrInterfaceDeclaration.class;
    }

    @Override
    public Object visit(final JavaNode node, final Object data) {
        if (nodeClass.isInstance(node)) {
            final DataPoint point = new DataPoint();
            point.setNode(node);
            point.setScore(1.0 * (node.getEndLine() - node.getBeginLine()));
            point.setMessage(getMessage() + " (V6)");
            addDataPoint(point);
        }

        return node.childrenAccept(this, data);
    }

}
