I'm new to PMD custom rule generation. I have written a small piece of code as
explained in the PMD tutorial.
I have the custom rules xml as well.
When i am trying to run with the pmd.bat "pmd.bat D:\PMDTestSrc\src xml
D:\A\bin\myPMD.xml" in wondows, it was throwing an error saying class not
found.
As your class is not found this is most likely a classpath issue. Are you sure
you added either the .class file with rule or the jar containing it to your
classpath ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was running PMD in the following manner:
pmd C:\Users\Rohit Gopalan\Documents\2012\FinalYearProject\PMD
Rules\project\src text C:\Users\Rohit
Gopalan\Documents\2012\FinalYearProject\PMD
Rules\project\src\projectRuleSet.xml
The issue I'm getting is an IllegalArgumentException as 'text' was recognised
as an Unknown option. I am trying to print a text file of violations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It looks like you have spaces in your file paths. Any command-line tool will
have problems parsing that effectively so i would suggest changing that for
starters. Have you tried the other output options as well?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Brian
The change of directories for the java and xml files worked.
I had tried debug for the previous attempt, but your suggestion works wonders
Cheers
Rohit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a new problem and it could be within my XML ruleset file.
I tried to run the following D:\FYP\PMD\build\classes\Project text
D:\FYP\PMD\src\Project\projectRuleSet.xml
the following error appeared: Cannot find class DataClassRule
I fixed some bugs in my XML ruleset file.
Here it is
Hi ,
I'm new to PMD custom rule generation. I have written a small piece of code as
explained in the PMD tutorial.
I have the custom rules xml as well.
When i am trying to run with the pmd.bat "pmd.bat D:\PMDTestSrc\src xml
D:\A\bin\myPMD.xml" in wondows, it was throwing an error saying class not
found.
Rule set xml is as follows:
<?xml version="1.0"?>
<ruleset name="My custom rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd&
quot;>
<rule name="NameList"
message="Try extending PMD"
class="com.kiran.sample.ASTNameFind">
<description>
Try extending PMD
</description>
<priority>3</priority>
<example>
<![CDATA]>
</example>
</rule>
</ruleset>
Please let me know where i have gone wrong.
Thanks and Regards
Kiran
Hi,
As your class is not found this is most likely a classpath issue. Are you sure
you added either the .class file with rule or the jar containing it to your
classpath ?
Hi rpelisse ,
Thank you. It was a classpath problem. Now i am able to run.
Regards
Kiran
I am having serious issues on how to run PMD. I am running it for the first
time through command line.
Just wondering if someone can help me out.
Here is my ruleset xml file
<root>
<ruleset name="Project Rules" <br="">xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<rule name="AvoidDataClass" <br="">message ="Add more methods than the getter and setter methods"
class="Project.DataClassRule" >
<description>
Add more methdos than the getter and setter methods
</description>
<example>
<! [CDATA]>
</example> </rule></ruleset></root>
I was running PMD in the following manner:
pmd C:\Users\Rohit Gopalan\Documents\2012\FinalYearProject\PMD
Rules\project\src text C:\Users\Rohit
Gopalan\Documents\2012\FinalYearProject\PMD
Rules\project\src\projectRuleSet.xml
The issue I'm getting is an IllegalArgumentException as 'text' was recognised
as an Unknown option. I am trying to print a text file of violations.
It looks like you have spaces in your file paths. Any command-line tool will
have problems parsing that effectively so i would suggest changing that for
starters. Have you tried the other output options as well?
Thanks Brian
The change of directories for the java and xml files worked.
I had tried debug for the previous attempt, but your suggestion works wonders
Cheers
Rohit
I have a new problem and it could be within my XML ruleset file.
I tried to run the following D:\FYP\PMD\build\classes\Project text
D:\FYP\PMD\src\Project\projectRuleSet.xml
the following error appeared: Cannot find class DataClassRule
I fixed some bugs in my XML ruleset file.
Here it is
<ruleset name="Project Rules" <br="">xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<rule name="AvoidDataClass" <br="">message ="Add more methods than the getter and setter methods"
class="DataClassRule">
<description>
Add more methdos than the getter and setter methods
</description>
<priority>
3
</priority>
<example>
<![CDATA]>
</example>
</rule>
</ruleset>
Please offer suggestions to help me out.
class="my.full.packagename.DataClassRule"
package name of DataClassRule class is Project.
Brian, will you be able to elaborate the 'my.full.packagename' bit please?
Such as give an example.