pmd: Fix broken docs regarding new CLI tool usage

This commit is contained in:
Romain PELISSE
2012-11-14 21:56:01 +01:00
parent 1de9f7cd49
commit a887700c8f
2 changed files with 16 additions and 43 deletions

View File

@ -60,7 +60,7 @@ public class PMDCommandLineInterface {
+ "3) A ruleset filename or a comma-delimited string of ruleset filenames" + PMD.EOL
+ PMD.EOL
+ "For example: " + PMD.EOL
+ "c:\\> " + launchCmd + " c:\\my\\source\\code html java-unusedcode" + PMD.EOL
+ "c:\\> " + launchCmd + "-d c:\\my\\source\\code -f html -R java-unusedcode" + PMD.EOL
+ PMD.EOL;
fullText += supportedVersions() + PMD.EOL;
@ -87,10 +87,10 @@ public class PMDCommandLineInterface {
final String WINDOWS_PATH_TO_CODE = "c:\\my\\source\\code";
return "For example on windows: " + PMD.EOL
+ WINDOWS_PROMPT + launchCmd + " -dir" + WINDOWS_PATH_TO_CODE + "-format text java-unusedcode,java-imports -version 1.5 -language java -debug" + PMD.EOL
+ WINDOWS_PROMPT + launchCmd + " -dir" + WINDOWS_PATH_TO_CODE + "-format text -R java-unusedcode,java-imports -version 1.5 -language java -debug" + PMD.EOL
+ WINDOWS_PROMPT + launchCmd + " -dir" + WINDOWS_PATH_TO_CODE + "-f xml -rulesets java-basic,java-design -encoding UTF-8" + PMD.EOL
+ WINDOWS_PROMPT + launchCmd + " -d" + WINDOWS_PATH_TO_CODE + "-rulesets java-typeresolution -auxclasspath commons-collections.jar;derby.jar" + PMD.EOL
+ WINDOWS_PROMPT + launchCmd + " -d" + WINDOWS_PATH_TO_CODE + "-f html java-typeresolution -auxclasspath file:///C:/my/classpathfile" + PMD.EOL
+ WINDOWS_PROMPT + launchCmd + " -d" + WINDOWS_PATH_TO_CODE + "-f html -R java-typeresolution -auxclasspath -d file:///C:/my/classpathfile" + PMD.EOL
+ PMD.EOL;
}

View File

@ -15,7 +15,7 @@
<p>The first argument is the name of the utility you want to execute ('pmd', 'designer',...) and the other arguments are
specific to the utility used.</p>
<source>
$ ./bin/run.sh pmd ../../../src/main/java/ text rulesets/java/basic.xml -version java 1.7
$ ./bin/run.sh pmd -d ../../../src/main/java/ -f text -R rulesets/java/basic.xml -version 1.7 -language java
.../src/main/java/net/sourceforge/pmd/RuleSet.java:123 These nested if statements could be combined
.../src/main/java/net/sourceforge/pmd/RuleSet.java:231 Useless parentheses.
.../src/main/java/net/sourceforge/pmd/RuleSet.java:232 Useless parentheses.
@ -29,7 +29,7 @@ $ ./bin/run.sh pmd ../../../src/main/java/ text rulesets/java/basic.xml -versio
<li><strong>Windows:</strong> Type &quot;pmd [filename|jar or zip file containing source code|directory] [report format] [ruleset file]&quot;, i.e:</li>
<br/>
<source>
C:\tmp\pmd-@VERSION@\pmd\bin&gt;pmd c:\data\pmd\pmd\test-data\Unused1.java xml rulesets/java/unusedcode.xml
C:\tmp\pmd-@VERSION@\pmd\bin&gt;pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R rulesets/java/unusedcode.xml
&lt;?xml version="1.0"?&gt;&lt;pmd&gt;
&lt;file name="c:\data\pmd\pmd\test-data\Unused1.java"&gt;
&lt;violation line="5" rule="UnusedLocalVariable"&gt;
@ -47,16 +47,17 @@ C:\tmp\pmd-@VERSION@\pmd\bin&gt;
<li>If you want to run PMD without the batch file, you can do a:</li>
<source>
C:\tmp\pmd-@VERSION@\pmd&gt;java -Djava.ext.dirs=lib
C:\tmp\pmd-@VERSION@\pmd&gt;java -Djava.ext.dirs=lib
net.sourceforge.pmd.PMD
c:\j2sdk1.4.1_01\src\java\lang xml
rulesets/java/imports.xml
-d c:\j2sdk1.4.1_01\src\java\lang
-f xml
-R rulesets/java/imports.xml
</source>
<br/>
<li><strong>Linux:</strong> Type &quot;./run.sh pmd [filename|jar or zip file containing source code|directory] [report format] [ruleset file]&quot;, i.e:</li>
<br/>
<source>
/home/user/tmp/pmd-@VERSION@/pmd/bin&gt;./run.sh pmd /home/user/data/pmd/pmd/test-data/Unused1.java xml rulesets/java/unusedcode.xml
/home/user/tmp/pmd-@VERSION@/pmd/bin&gt;./run.sh pmd -d /home/user/data/pmd/pmd/test-data/Unused1.java -f xml -R rulesets/java/unusedcode.xml
&lt;?xml version="1.0"?&gt;&lt;pmd&gt;
&lt;file name="/home/user/data/pmd/pmd/test-data/Unused1.java"&gt;
&lt;violation line="5" rule="UnusedLocalVariable"&gt;
@ -69,47 +70,19 @@ Avoid unused local variables such as 'fr'
</ul>
</subsection>
<subsection name="Other options">
<ul>
<li>Notice that in this case the output is in XML, so you can redirect it to a file and optionally transform it via XSLT</li>
<li>You can also use shortened names to refer to the built-in rulesets, like this:</li>
<source>
java net.sourceforge.pmd.PMD /path/to/source text java-basic,java-imports,java-unusedcode
</source>
<li>The command line interface also accepts the following optional arguments:</li>
<ul>
<li><code>-version</code> - specify version of a language PMD should use (example: -version java 1.7 or -version cpp).</li>
<li><code>-debug</code> - prints a stacktrace if an error is encountered</li>
<li><code>-shortnames</code> - puts shortened names in the report. This only works if the filename argument is a single directory</li>
<li><code>-encoding Cp1252</code> - uses the specified encoding for reading the source code files</li>
<li><code>-excludemarker NOPMDFORME</code> - uses the specified string of characters as the marker for PMD to ignore. The default string is "NOPMD".</li>
<li><code>-linkprefix</code> - path to HTML source, for summary html renderer only.</li>
<li><code>-lineprefix</code> - custom anchor to affected line in the source file, for summary html renderer only.</li>
<li><code>-minimumpriority</code> - The rule priority threshold; rules with lower priority than they will not be used.</li>
<li><code>-xslt FILENAME</code> - This option overrides the default XSL stylesheet used by nicehtml renderer.</li>
</ul>
</ul>
</subsection>
<p>The tool comes with a rather extensive help text, simply running with --help !</p>
</subsection>
<subsection name="Renderers">
<p>PMD comes with four different renderer types:
<ul>
<li><b>text</b>, provides a basic text output.</li>
<ul>
<li><b>csv</b>, provides a Comma Separated Values.</li>
<li><b>text</b>, provides a basic text output.</li>
<li><b>xml</b>, provides report output in XML format.</li>
<li><b>html</b>, provides report as a basic HTML page.</li>
<li><b>nicehtml</b>, provides an enhanced HTML output page.
As this feature use an XSLT transformation, it also possible to override the default stylesheet using the -xslt parameter.</li>
<li>... and many more ! See the tool help text...</li>
</ul>
</p>
<p>Here is a simple example of 'nicehtml' feature usage:
<source>
java net.sourceforge.pmd.PMD /path/to/source nicehtml java-basic,java-imports,java-unusedcode -xslt my-own-stylesheet.xsl
</source>
<i>Note that the stylesheet should be a readable file for PMD.</i>
</p>
</subsection>
</section>
</body>
</document>