|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
2 | 2 |
|
3 | 3 | <project name="Phing static code analysis" default="all">
|
4 |
| - <!-- Properties --> |
5 |
| - <property name="dir.base" value="." /> |
6 |
| - <property name="dir.tests" value="${project.basedir}/tests" /> |
7 |
| - <property name="dir.tests.unit" value="${project.basedir}/tests" /> |
8 |
| - <property name="dir.build" value="${project.basedir}/phing-build" /> |
9 |
| - <property name="dir.docs" value="${dir.build}/docs" /> |
10 |
| - <property name="dir.docs.phpdoc" value="${dir.docs}/phpdoc" /> |
11 |
| - <property name="dir.reports" value="${dir.build}/logs" /> |
12 |
| - <property name="dir.reports.pdepend" value="${dir.reports}/pdepend" /> |
13 |
| - <property name="dir.reports.unit" value="${dir.reports}/phpunit" /> |
14 |
| - <property name="dir.reports.coverage" value="${dir.reports}/phpunit/coverage" /> |
15 |
| - <property name="dir.reports.build" value="${dir.reports}/htmlreport" /> |
| 4 | + <!-- Properties --> |
| 5 | + <property name="dir.base" value="." /> |
| 6 | + <property name="dir.tests" value="${project.basedir}/tests" /> |
| 7 | + <property name="dir.tests.unit" value="${project.basedir}/tests" /> |
| 8 | + <property name="dir.build" value="${project.basedir}/phing-build" /> |
| 9 | + <property name="dir.docs" value="${dir.build}/docs" /> |
| 10 | + <property name="dir.docs.phpdoc" value="${dir.docs}/phpdoc" /> |
| 11 | + <property name="dir.reports" value="${dir.build}/logs" /> |
| 12 | + <property name="dir.reports.pdepend" value="${dir.reports}/pdepend" /> |
| 13 | + <property name="dir.reports.unit" value="${dir.reports}/phpunit" /> |
| 14 | + <property name="dir.reports.coverage" value="${dir.reports}/phpunit/coverage" /> |
| 15 | + <property name="dir.reports.build" value="${dir.reports}/htmlreport" /> |
16 | 16 |
|
17 |
| - <!-- ============================================ --> |
18 |
| - <!-- Fileset: sources (all php files but those in test) --> |
19 |
| - <!-- ============================================ --> |
20 |
| - <fileset expandsymboliclinks="true" dir="${dir.base}" id="sources"> |
21 |
| - <include name="src/**/*.php" /> |
22 |
| - </fileset> |
| 17 | + <!-- ============================================ --> |
| 18 | + <!-- Fileset: sources (all php files but those in test) --> |
| 19 | + <!-- ============================================ --> |
| 20 | + <fileset expandsymboliclinks="true" dir="${dir.base}" id="sources"> |
| 21 | + <include name="src/**/*.php" /> |
| 22 | + </fileset> |
23 | 23 |
|
24 |
| - <!-- ============================================ --> |
25 |
| - <!-- Target: clean --> |
26 |
| - <!-- ============================================ --> |
27 |
| - <target name="clean" description="Clean up build directories."> |
28 |
| - <echo msg="Cleaning build directories ..." /> |
29 |
| - <delete dir="${dir.build}" verbose="false" /> |
30 |
| - </target> |
| 24 | + <!-- ============================================ --> |
| 25 | + <!-- Target: clean --> |
| 26 | + <!-- ============================================ --> |
| 27 | + <target name="clean" description="Clean up build directories."> |
| 28 | + <echo msg="Cleaning build directories ..." /> |
| 29 | + <delete dir="${dir.build}" verbose="false" /> |
| 30 | + </target> |
31 | 31 |
|
32 |
| - <!-- ============================================ --> |
33 |
| - <!-- Target: prepare --> |
34 |
| - <!-- ============================================ --> |
35 |
| - <target name="prepare" description="Create build directories."> |
36 |
| - <echo msg="Creating build directories ..." /> |
37 |
| - <mkdir dir="${dir.build}" /> |
38 |
| - <mkdir dir="${dir.docs}" /> |
39 |
| - <mkdir dir="${dir.docs.phpdoc}" /> |
40 |
| - <mkdir dir="${dir.reports}" /> |
41 |
| - <mkdir dir="${dir.reports.unit}" /> |
42 |
| - <mkdir dir="${dir.reports.coverage}" /> |
43 |
| - <mkdir dir="${dir.reports.pdepend}" /> |
44 |
| - <mkdir dir="${dir.reports.build}" /> |
45 |
| - </target> |
| 32 | + <!-- ============================================ --> |
| 33 | + <!-- Target: prepare --> |
| 34 | + <!-- ============================================ --> |
| 35 | + <target name="prepare" description="Create build directories."> |
| 36 | + <echo msg="Creating build directories ..." /> |
| 37 | + <mkdir dir="${dir.build}" /> |
| 38 | + <mkdir dir="${dir.docs}" /> |
| 39 | + <mkdir dir="${dir.docs.phpdoc}" /> |
| 40 | + <mkdir dir="${dir.reports}" /> |
| 41 | + <mkdir dir="${dir.reports.unit}" /> |
| 42 | + <mkdir dir="${dir.reports.coverage}" /> |
| 43 | + <mkdir dir="${dir.reports.pdepend}" /> |
| 44 | + <mkdir dir="${dir.reports.build}" /> |
| 45 | + </target> |
46 | 46 |
|
47 |
| - <!-- ============================================ --> |
48 |
| - <!-- Target: all (default target) --> |
49 |
| - <!-- ============================================ --> |
50 |
| - <target name="all" depends="clean, prepare"> |
51 |
| - <phingcall target="codecheck" /> |
52 |
| - <phingcall target="tests" /> |
53 |
| - </target> |
| 47 | + <!-- ============================================ --> |
| 48 | + <!-- Target: all (default target) --> |
| 49 | + <!-- ============================================ --> |
| 50 | + <target name="all" depends="clean, prepare"> |
| 51 | + <phingcall target="codecheck" /> |
| 52 | + <phingcall target="tests" /> |
| 53 | + <phingcall target="documentation" /> |
| 54 | + </target> |
54 | 55 |
|
55 |
| - <!-- ============================================ --> |
56 |
| - <!-- Target: codecheck (run all static code checks) --> |
57 |
| - <!-- ============================================ --> |
58 |
| - <target name="codecheck"> |
59 |
| - <phingcall target="lint" /> |
60 |
| - <phingcall target="codestyle" /> |
61 |
| - <phingcall target="mess" /> |
62 |
| - <phingcall target="copypaste" /> |
63 |
| - </target> |
| 56 | + <!-- ============================================ --> |
| 57 | + <!-- Target: codecheck (run all static code checks) --> |
| 58 | + <!-- ============================================ --> |
| 59 | + <target name="codecheck"> |
| 60 | + <phingcall target="lint" /> |
| 61 | + <phingcall target="codestyle" /> |
| 62 | + <phingcall target="mess" /> |
| 63 | + <phingcall target="copypaste" /> |
| 64 | + <phingcall target="measure" /> |
| 65 | + </target> |
64 | 66 |
|
65 |
| - <!-- ============================================ --> |
66 |
| - <!-- Target: tests (run all tests) --> |
67 |
| - <!-- ============================================ --> |
68 |
| - <target name="tests"> |
69 |
| - <!-- Now we are not running unit tests --> |
70 |
| - <phingcall target="unittests" /> |
71 |
| - </target> |
| 67 | + <!-- ============================================ --> |
| 68 | + <!-- Target: tests (run all tests) --> |
| 69 | + <!-- ============================================ --> |
| 70 | + <target name="tests"> |
| 71 | + <!-- Now we are not running unit tests --> |
| 72 | + <phingcall target="unittests" /> |
| 73 | + </target> |
72 | 74 |
|
73 |
| - <!-- ============================================ --> |
74 |
| - <!-- Target: lint (Checks code syntax) --> |
75 |
| - <!-- ============================================ --> |
76 |
| - <target name="lint"> |
77 |
| - <echo msg="Running lint to check code syntax..." /> |
78 |
| - <phplint> |
79 |
| - <fileset refid="sources" /> |
80 |
| - </phplint> |
81 |
| - </target> |
82 |
| - |
83 |
| - <!-- ============================================ --> |
84 |
| - <!-- Target: codestyle (Checks code style compliance) --> |
85 |
| - <!-- ============================================ --> |
86 |
| - <target name="codestyle"> |
87 |
| - <echo msg="Running code sniffer to check PSR2 standard..." /> |
88 |
| - <phpcodesniffer standard="PSR2" showSniffs="true" showWarnings="true" verbosity="0" encoding="UTF-8"> |
89 |
| - <fileset refid="sources" /> |
90 |
| - <formatter type="full" outfile="${dir.reports}/reportcs.txt" /> |
91 |
| - <formatter type="checkstyle" outfile="${dir.reports}/checkstylecs.xml" /> |
92 |
| - </phpcodesniffer> |
93 |
| - </target> |
| 75 | + <!-- ============================================ --> |
| 76 | + <!-- Target: lint (Checks code syntax) --> |
| 77 | + <!-- ============================================ --> |
| 78 | + <target name="lint"> |
| 79 | + <echo msg="Running lint to check code syntax..." /> |
| 80 | + <phplint> |
| 81 | + <fileset refid="sources" /> |
| 82 | + </phplint> |
| 83 | + </target> |
| 84 | + |
| 85 | + <!-- ============================================ --> |
| 86 | + <!-- Target: codestyle (Checks code style compliance) --> |
| 87 | + <!-- ============================================ --> |
| 88 | + <target name="codestyle"> |
| 89 | + <echo msg="Running code sniffer to check PSR2 standard..." /> |
| 90 | + <phpcodesniffer standard="PSR2" showSniffs="true" showWarnings="true" verbosity="0" encoding="UTF-8"> |
| 91 | + <fileset refid="sources" /> |
| 92 | + <formatter type="full" outfile="${dir.reports}/reportcs.txt" /> |
| 93 | + <formatter type="checkstyle" outfile="${dir.reports}/checkstylecs.xml" /> |
| 94 | + </phpcodesniffer> |
| 95 | + </target> |
94 | 96 |
|
95 |
| - <!-- ============================================ --> |
96 |
| - <!-- Target: mess (Detects mess in code. Recommended rulesets: --> |
97 |
| - <!-- unusedcode,codesize,controversial,design,naming) --> |
98 |
| - <!-- It can be also used as <pmd> tag. --> |
99 |
| - <!-- ============================================ --> |
100 |
| - <target name="mess"> |
101 |
| - <echo msg="Running mess detector" /> |
102 |
| - <phpmd rulesets="unusedcode,codesize,controversial,design,naming"> |
103 |
| - <fileset refid="sources" /> |
104 |
| - <formatter type="xml" outfile="${dir.reports}/pmd.xml"/> |
105 |
| - </phpmd> |
106 |
| - </target> |
| 97 | + <!-- ============================================ --> |
| 98 | + <!-- Target: mess (Detects mess in code. Recommended rulesets: --> |
| 99 | + <!-- unusedcode,codesize,controversial,design,naming) --> |
| 100 | + <!-- It can be also used as <pmd> tag. --> |
| 101 | + <!-- ============================================ --> |
| 102 | + <target name="mess"> |
| 103 | + <echo msg="Running mess detector" /> |
| 104 | + <phpmd rulesets="unusedcode,codesize,controversial,design,naming"> |
| 105 | + <fileset refid="sources" /> |
| 106 | + <formatter type="xml" outfile="${dir.reports}/pmd.xml"/> |
| 107 | + </phpmd> |
| 108 | + </target> |
107 | 109 |
|
108 |
| - <!-- ============================================ --> |
109 |
| - <!-- Target: copypaste (detects copy/paste in code) --> |
110 |
| - <!-- ============================================ --> |
111 |
| - <target name="copypaste"> |
112 |
| - <echo msg="Running copy/paste detector..." /> |
113 |
| - <phpcpd> |
114 |
| - <fileset refid="sources" /> |
115 |
| - <formatter type="pmd" outfile="${dir.reports}/pmd-cpd.xml" /> |
116 |
| - </phpcpd> |
117 |
| - </target> |
| 110 | + <!-- ============================================ --> |
| 111 | + <!-- Target: copypaste (detects copy/paste in code) --> |
| 112 | + <!-- ============================================ --> |
| 113 | + <target name="copypaste"> |
| 114 | + <echo msg="Running copy/paste detector..." /> |
| 115 | + <phpcpd> |
| 116 | + <fileset refid="sources" /> |
| 117 | + <formatter type="pmd" outfile="${dir.reports}/pmd-cpd.xml" /> |
| 118 | + </phpcpd> |
| 119 | + </target> |
118 | 120 |
|
| 121 | + <!-- ============================================ --> |
| 122 | + <!-- Target: measure (measures the code) --> |
| 123 | + <!-- ============================================ --> |
| 124 | + <target name="measure"> |
| 125 | + <echo msg="Running code measurements..." /> |
| 126 | + <phploc reportType="csv" reportName="phploc" reportDirectory="${dir.reports}"> |
| 127 | + <fileset refid="sources" /> |
| 128 | + </phploc> |
| 129 | + <phpdepend> |
| 130 | + <fileset refid="sources" /> |
| 131 | + <logger type="jdepend-xml" outfile="${dir.reports}/jdepend.xml"/> |
| 132 | + <analyzer type="coderank-mode" value="method"/> |
| 133 | + </phpdepend> |
| 134 | + </target> |
| 135 | + |
119 | 136 | <!-- ============================================ -->
|
120 |
| - <!-- Target: measure (measures the code) --> |
121 |
| - <!-- ============================================ --> |
122 |
| - <target name="measure"> |
123 |
| - <echo msg="Running code measurements..." /> |
124 |
| - <phploc reportType="csv" reportName="phploc" reportDirectory="${dir.reports}"> |
125 |
| - <fileset refid="sources" /> |
126 |
| - </phploc> |
127 |
| - </target> |
128 |
| - |
129 |
| - <!-- ============================================ --> |
130 |
| - <!-- Target: unittests (unit testing) --> |
131 |
| - <!-- ============================================ --> |
132 |
| - <target name="unittests"> |
133 |
| - <echo msg="Running unit tests..." /> |
134 |
| - <coverage-setup database="${dir.reports.unit}/coverage.db"> |
| 137 | + <!-- Target: documentation (PHP Documentor parsing) --> |
| 138 | + <!-- ============================================ --> |
| 139 | + <target name="documentation"> |
| 140 | + <phpdoc2 title="Project Documentation" destdir="${dir.docs.phpdoc}" template="responsive-twig"> |
| 141 | + <fileset refid="sources" /> |
| 142 | + </phpdoc2> |
| 143 | + </target> |
| 144 | + |
| 145 | + <!-- ============================================ --> |
| 146 | + <!-- Target: unittests (unit testing) --> |
| 147 | + <!-- ============================================ --> |
| 148 | + <target name="unittests"> |
| 149 | + <echo msg="Running unit tests..." /> |
| 150 | + <coverage-setup database="${dir.reports.unit}/coverage.db"> |
135 | 151 | <fileset refid="sources" />
|
136 | 152 | </coverage-setup>
|
137 | 153 | <phpunit configuration="${dir.tests}/phpunit.xml" codecoverage="true">
|
138 | 154 | <formatter todir="${dir.reports.unit}" type="xml" />
|
139 |
| - <formatter todir="${dir.reports.unit}" type="clover" /> |
| 155 | + <formatter todir="${dir.reports.unit}" type="clover" /> |
140 | 156 | <batchtest>
|
141 | 157 | <fileset dir="${dir.tests.unit}" />
|
142 | 158 | </batchtest>
|
143 | 159 | </phpunit>
|
144 |
| - <coverage-report outfile="${dir.reports.unit}/coverage.xml"> |
145 |
| - <report todir="${dir.reports.coverage}" title="Phing unit tests run" usesorttable="true"/> |
146 |
| - </coverage-report> |
147 |
| - </target> |
| 160 | + <coverage-report outfile="${dir.reports.unit}/coverage.xml"> |
| 161 | + <report todir="${dir.reports.coverage}" title="Phing unit tests run" usesorttable="true"/> |
| 162 | + </coverage-report> |
| 163 | + </target> |
148 | 164 | </project>
|
0 commit comments