I am trying to run the sample PMD custom rule as described in http://pmd.sourceforge.net/pmd-5.3.2/customizing/howtowritearule.html#Write_a_rule_class and I am unable to compile/run it in eclipse. I am not sure what is missing. I added the external PMD jar files on my project to get rid of import issues but I just can't run it. Can anyone please help or give me a sample rule that runs on eclipse. I am a beginner and I want a sample that works. I basically needs to compile the .java rule file sothat I get a .class file that I can eventually convert to jar to use that rule in Jenkins with Gradle.
@Suman I am also facing difficulty in building pmd-apex in order to develop new rule. I am getting error for pmd-apex-jorje is missing for pmd-apex module. Please let me know incase you find any solution to the same.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to run the sample PMD custom rule as described in http://pmd.sourceforge.net/pmd-5.3.2/customizing/howtowritearule.html#Write_a_rule_class and I am unable to compile/run it in eclipse. I am not sure what is missing. I added the external PMD jar files on my project to get rid of import issues but I just can't run it. Can anyone please help or give me a sample rule that runs on eclipse. I am a beginner and I want a sample that works. I basically needs to compile the .java rule file sothat I get a .class file that I can eventually convert to jar to use that rule in Jenkins with Gradle.
import net.sourceforge.pmd.lang.ast.;
import net.sourceforge.pmd.lang.java.ast.;
import net.sourceforge.pmd.lang.java.rule.*;
public class WhileLoopsMustUseBracesRule extends AbstractJavaRule {
public Object visit(ASTWhileStatement node, Object data) {
Node firstStmt = node.jjtGetChild(1);
if (!hasBlockAsFirstChild(firstStmt)) {
addViolation(data, node);
}
return super.visit(node,data);
}
private boolean hasBlockAsFirstChild(Node node) {
return (node.jjtGetNumChildren() != 0 && (node.jjtGetChild(0) instanceof ASTBlock));
}
}
@Suman I am also facing difficulty in building pmd-apex in order to develop new rule. I am getting error for pmd-apex-jorje is missing for pmd-apex module. Please let me know incase you find any solution to the same.