Hi all, i have a quick question on the pmd rule designer. From the pmd rule desginer itself, there is an option availabe for for developers to insert a new xml java rule. The xml java rule would be based on an existing java class. Take for instance
<?xml version="1.0"?><rulesetname="myrules"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="../etc/ruleset_xml_schema.xml"><description>
The ‘myrules’ ruleset contains my rules. Aptly named!
</description><rulename="EmptyIfStmt"message="Avoid empty 'if' statements"class="net.sourceforge.pmd.rules.EmptyIf"><description>
Avoid empty 'if' statements
</description><priority>3</priority><example><![CDATA[if (foo == 0) {// why bother checking up on foo?}]]></example></rule></ruleset>
From the xml file above, we can see that this xml rule file is referencing from a existing java class, namely "net.sourceforge.pmd.rules.EmptyIf". My question is this, where should I store this java class at? If i were to store "EmptyIf.java" in a folder named "net.sourceforge.pmd.rules" which is located on the desktop, would pmd be able to find this java class when I call the EmptyIf rule? Furthermore, do i have to compile this java class?
Thank you all
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's in general easier to have your custom rule run from within commandline or via maven. If you want to run a custom rule in pmd eclipse, you would need to create an extension eclipse plugin, so that the pmd within eclipse knows about your new rule.
Regards,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HI All,
I am trying to create Xpath rule for Apex.
I checked the existing Apex xpath rule, it has implementation Class: net.sourceforge.pmd.lang.apex.rule.ApexXPathRule
While creating new Xpath rule, I am not getting option to choose implementation Class, it automatically takes net.sourceforge.pmd.lang.rule.XPathRule path.
So my new rule is not getting fired for apex class.
Please assist.
Regards,
Swapnali
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all, i have a quick question on the pmd rule designer. From the pmd rule desginer itself, there is an option availabe for for developers to insert a new xml java rule. The xml java rule would be based on an existing java class. Take for instance
From the xml file above, we can see that this xml rule file is referencing from a existing java class, namely "net.sourceforge.pmd.rules.EmptyIf". My question is this, where should I store this java class at? If i were to store "EmptyIf.java" in a folder named "net.sourceforge.pmd.rules" which is located on the desktop, would pmd be able to find this java class when I call the EmptyIf rule? Furthermore, do i have to compile this java class?
Thank you all
You'll have to compile your java code first - in the example, it's the file
net/sourceforge/pmd/rules/EmptyIf.java
.I'd checkout this discussion: https://sourceforge.net/p/pmd/discussion/188192/thread/c65364da/#3867
and this one: http://stackoverflow.com/questions/33758639/how-to-add-a-custom-pmd-rule-in-jenkins-pmd-plugin - this is a maven based solution.
It's in general easier to have your custom rule run from within commandline or via maven. If you want to run a custom rule in pmd eclipse, you would need to create an extension eclipse plugin, so that the pmd within eclipse knows about your new rule.
Regards,
Andreas
Could anyone give idea of create custom rule with java using eclipse ide luna
Hi Luv,
did you see the general documentation about it? How to write a rule
HI All,
I am trying to create Xpath rule for Apex.
I checked the existing Apex xpath rule, it has implementation Class: net.sourceforge.pmd.lang.apex.rule.ApexXPathRule
While creating new Xpath rule, I am not getting option to choose implementation Class, it automatically takes net.sourceforge.pmd.lang.rule.XPathRule path.
So my new rule is not getting fired for apex class.
Please assist.
Regards,
Swapnali