From a887700c8fba2d1a322d727841c137e8aeca8375 Mon Sep 17 00:00:00 2001
From: Romain PELISSE
Date: Wed, 14 Nov 2012 21:56:01 +0100
Subject: [PATCH] pmd: Fix broken docs regarding new CLI tool usage
---
.../pmd/cli/PMDCommandLineInterface.java | 6 +--
pmd/src/site/xdocs/running.xml | 53 +++++--------------
2 files changed, 16 insertions(+), 43 deletions(-)
diff --git a/pmd/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java b/pmd/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java
index 205f035b4e..94818e6baa 100644
--- a/pmd/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java
+++ b/pmd/src/main/java/net/sourceforge/pmd/cli/PMDCommandLineInterface.java
@@ -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;
}
diff --git a/pmd/src/site/xdocs/running.xml b/pmd/src/site/xdocs/running.xml
index f418b9f5cc..6fbd8601ee 100644
--- a/pmd/src/site/xdocs/running.xml
+++ b/pmd/src/site/xdocs/running.xml
@@ -15,7 +15,7 @@
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.
-$ ./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
Windows: Type "pmd [filename|jar or zip file containing source code|directory] [report format] [ruleset file]", i.e:
-C:\tmp\pmd-@VERSION@\pmd\bin>pmd c:\data\pmd\pmd\test-data\Unused1.java xml rulesets/java/unusedcode.xml
+C:\tmp\pmd-@VERSION@\pmd\bin>pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R rulesets/java/unusedcode.xml
<?xml version="1.0"?><pmd>
<file name="c:\data\pmd\pmd\test-data\Unused1.java">
<violation line="5" rule="UnusedLocalVariable">
@@ -47,16 +47,17 @@ C:\tmp\pmd-@VERSION@\pmd\bin>
If you want to run PMD without the batch file, you can do a:
-C:\tmp\pmd-@VERSION@\pmd>java -Djava.ext.dirs=lib
+C:\tmp\pmd-@VERSION@\pmd>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
Linux: Type "./run.sh pmd [filename|jar or zip file containing source code|directory] [report format] [ruleset file]", i.e:
-/home/user/tmp/pmd-@VERSION@/pmd/bin>./run.sh pmd /home/user/data/pmd/pmd/test-data/Unused1.java xml rulesets/java/unusedcode.xml
+/home/user/tmp/pmd-@VERSION@/pmd/bin>./run.sh pmd -d /home/user/data/pmd/pmd/test-data/Unused1.java -f xml -R 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">
@@ -69,47 +70,19 @@ Avoid unused local variables such as 'fr'
-
- Notice that in this case the output is in XML, so you can redirect it to a file and optionally transform it via XSLT
- You can also use shortened names to refer to the built-in rulesets, like this:
-
-java net.sourceforge.pmd.PMD /path/to/source text java-basic,java-imports,java-unusedcode
-
- The command line interface also accepts the following optional arguments:
-
- -version
- specify version of a language PMD should use (example: -version java 1.7 or -version cpp).
- -debug
- prints a stacktrace if an error is encountered
- -shortnames
- puts shortened names in the report. This only works if the filename argument is a single directory
- -encoding Cp1252
- uses the specified encoding for reading the source code files
- -excludemarker NOPMDFORME
- uses the specified string of characters as the marker for PMD to ignore. The default string is "NOPMD".
- -linkprefix
- path to HTML source, for summary html renderer only.
- -lineprefix
- custom anchor to affected line in the source file, for summary html renderer only.
- -minimumpriority
- The rule priority threshold; rules with lower priority than they will not be used.
- -xslt FILENAME
- This option overrides the default XSL stylesheet used by nicehtml renderer.
-
-
-
+ The tool comes with a rather extensive help text, simply running with --help !
+
PMD comes with four different renderer types:
-
- text , provides a basic text output.
+
+ csv , provides a Comma Separated Values.
+ text , provides a basic text output.
xml , provides report output in XML format.
html , provides report as a basic HTML page.
- nicehtml , 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.
+ ... and many more ! See the tool help text...
- 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
-
- Note that the stylesheet should be a readable file for PMD.
-