C:\tmp\pmd-5.0.0\pmd\bin>pmd c:\data\pmd\pmd\test-data\Unused1.java xml rulesets/java/unusedcode.xml <?xml version="1.0"?><pmd> <file name="c:\data\pmd\pmd\test-data\Unused1.java"> <violation line="5" rule="UnusedLocalVariable"> Avoid unused local variables such as 'fr' </violation> </file></pmd> C:\tmp\pmd-5.0.0\pmd\bin>
You can pass a file name, a directory name, or a jar or zip file name containing Java source code to PMD.
Also, the PMD binary distribution includes the ruleset files inside the jar file - even though the "rulesets/java/unusedcode.xml" parameter above looks like a filesystem reference, it's really being used by a getResourceAsStream() call to load it out of the PMD jar file. And the same applies to the example below.
C:\tmp\pmd-5.0.0\pmd>java -Djava.ext.dirs=lib net.sourceforge.pmd.PMD c:\j2sdk1.4.1_01\src\java\lang xml rulesets/java/imports.xml
/home/user/tmp/pmd-5.0.0/pmd/bin>./run.sh pmd /home/user/data/pmd/pmd/test-data/Unused1.java xml rulesets/java/unusedcode.xml <?xml version="1.0"?><pmd> <file name="/home/user/data/pmd/pmd/test-data/Unused1.java"> <violation line="5" rule="UnusedLocalVariable"> Avoid unused local variables such as 'fr' </violation> </file></pmd> /home/user/tmp/pmd-5.0.0/pmd/bin>
java net.sourceforge.pmd.PMD /path/to/source text java-basic,java-imports,java-unusedcode
PMD comes with four different renderer types:
Here is a simple example of 'nicehtml' feature usage:
java net.sourceforge.pmd.PMD /path/to/source nicehtml java-basic,java-imports,java-unusedcode -xslt my-own-stylesheet.xsl