|
2 |
+================== |
|
3 |
+Command line usage |
|
4 |
+================== |
|
5 |
+ |
|
6 |
+Type phpmd [filename|directory] [report format] [ruleset file], i.e: :: |
|
7 |
+ |
|
8 |
+ mapi@arwen ~ $ phpmd PHP/Depend/DbusUI/ xml rulesets/codesize.xml |
|
9 |
+ <?xml version="1.0" encoding="UTF-8" ?> |
|
10 |
+ <pmd version="0.0.1" timestamp="2009-12-19T22:17:18+01:00"> |
|
11 |
+ <file name="/projects/pdepend/PHP/Depend/DbusUI/ResultPrinter.php"> |
|
12 |
+ <violation beginline="67" |
|
13 |
+ endline="224" |
|
14 |
+ rule="TooManyMethods" |
|
15 |
+ ruleset="Code Size Rules" |
|
16 |
+ package="PHP_Depend\DbusUI" |
|
17 |
+ class="PHP_Depend_DbusUI_ResultPrinter" |
|
18 |
+ priority="3"> |
|
19 |
+ This class has too many methods, consider refactoring it. |
|
20 |
+ </violation> |
|
21 |
+ </file> |
|
22 |
+ </pmd> |
|
23 |
+ |
|
24 |
+You can pass a file name or a directory name containing PHP source |
|
25 |
+code to PHPMD. |
|
26 |
+ |
|
27 |
+The PHPMD PEAR or Phar distribution includes the rule set files inside |
|
28 |
+its archive, even if the "rulesets/codesize.xml" parameter above looks |
|
29 |
+like a filesystem reference. |
|
30 |
+ |
|
31 |
+Command line options |
|
32 |
+==================== |
|
33 |
+ |
|
34 |
+- Notice that the default output is in XML, so you can redirect it to |
|
35 |
+ a file and XSLT it or whatever |
|
36 |
+ |
|
37 |
+- You can also use shortened names to refer to the built-in rule sets, |
|
38 |
+ like this: :: |
|
39 |
+ |
|
40 |
+ phpmd PHP/Depend/DbusUI/ xml codesize |
|
41 |
+ |
|
42 |
+- The command line interface also accepts the following optional arguments: |
|
43 |
+ |
|
44 |
+ - ``--minimumpriority`` - The rule priority threshold; rules with lower |
|
45 |
+ priority than they will not be used. |
|
46 |
+ |
|
47 |
+ - ``--reportfile`` - Sends the report output to the specified file, |
|
48 |
+ instead of the default output target ``STDOUT``. |
|
49 |
+ |
|
50 |
+ - ``--extensions`` - Comma separated string of valid PHP source file |
|
51 |
+ extensions. |
|
52 |
+ |
|
53 |
+ - ``--ignore`` - Comma separated string of files or directories that |
|
54 |
+ will be ignored during the parsing process. |
|
55 |
+ |
|
56 |
+Using multiple rule sets |
|
57 |
+```````````````````````` |
|
58 |
+ |
|
59 |
+PHPMD uses so called rule sets that configure/define a set of rules which will |
|
60 |
+be applied against the source under test. The default distribution of PHPMD is |
|
61 |
+already shipped with a few default sets, that can be used out-of-box. You can |
|
62 |
+call PHPMD's cli tool with a set's name to apply this configuration: :: |
|
63 |
+ |
|
64 |
+ ~ $ phpmd /path/to/source text codesize |
|
65 |
+ |
|
66 |
+But what if you would like to apply more than one rule set against your source? |
|
67 |
+You can also pass a list of rule set names, separated by comma to PHPMD's cli |
|
68 |
+tool: :: |
|
69 |
+ |
|
70 |
+ ~ $ phpmd /path/to/source text codesize,unusedcode,naming |
|
71 |
+ |
|
72 |
+You can also mix custom `rule set files`__ with build-in rule sets: :: |
|
73 |
+ |
|
74 |
+ ~ $ phpmd /path/to/source text codesize,/my/rules.xml |
|
75 |
+ |
|
76 |
+__ /documentation/creating-a-ruleset.html |
|
77 |
+ |
|
78 |
+That's it. With this behavior you can specify you own combination of rule sets |
|
79 |
+that will check the source code. |
|
80 |
+ |
|
81 |
+Exit codes |
|
82 |
+========== |
|
83 |
+ |
|
84 |
+PHPMD's command line tool currently defines three different exit codes. |
|
85 |
+ |
|
86 |
+- *0*, This exit code indicates that everything worked as expected. This means |
|
87 |
+ there was no error/exception and PHPMD hasn't detected any rule violation |
|
88 |
+ in the code under test. |
|
89 |
+- *1*, This exit code indicates that an error/exception occured which has |
|
90 |
+ interrupted PHPMD during execution. |
|
91 |
+- *2*, This exit code means that PHPMD has processed the code under test |
|
92 |
+ without the occurence of an error/exception, but it has detected rule |
|
93 |
+ violations in the analyzed source code. |
|
94 |
+ |
|
95 |
+Renderers |
|
96 |
+========= |
|
97 |
+ |
|
98 |
+At the moment PHPMD comes with the following three renderers: |
|
99 |
+ |
|
100 |
+- *xml*, which formats the report as XML. |
|
101 |
+- *text*, simple textual format. |
|
102 |
+- *html*, single HTML file with possible problems. |