-
Notifications
You must be signed in to change notification settings - Fork 57
/
phploc.xsl
375 lines (355 loc) · 19.5 KB
/
phploc.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:func="http://exslt.org/functions" extension-element-prefixes="func"
xmlns:phpqa="https://github.com/EdgedesignCZ/phpqa/functions"
version="1.0">
<!-- XSL from https://github.com/theseer/phpdox/blob/master/templates/html/index.xsl -->
<xsl:output method="html" indent="yes"/>
<func:function name="phpqa:format-number">
<xsl:param name="value"/>
<xsl:param name="format">0.##</xsl:param>
<func:result>
<xsl:choose>
<xsl:when test="string(number($value))='NaN'">
<xsl:value-of select="format-number(0, $format)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number($value, $format)"/>
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>
<xsl:template match="phploc">
<style>
.indent {
text-indent: 1em;
}
.indent2 {
text-indent: 2em;
}
.nummeric {
text-align: right;
}
.nummeric a {
display: block;
background-color: #CCD;
padding: 0 0.5em;
}
.nummeric a:hover, .nummeric a:focus, .nummeric a:active {
background-color: #DDE;
outline: dotted 2px #AAB;
}
.nummeric a:hover {
outline-style: solid;
}
.nummeric a:active {
outline: solid 2px #667;
}
.percent {
text-align: right;
width:5em;
}
nav {
margin-bottom: 1em;
}
</style>
<link rel="stylesheet"><xsl:attribute name="href"><xsl:value-of select="$bootstrap.min.css" /></xsl:attribute></link>
<div class="container">
<h1>phploc report</h1>
<nav>
<ul class="nav nav-pills" role="tablist">
<li role="presentation" class="active">
<a href="#overview" aria-controls="overview" role="tab" data-toggle="tab">Overview</a>
</li>
<li role="presentation">
<a href="#ccn" aria-controls="ccn" role="tab" data-toggle="tab">Cyclomatic Complexity</a>
</li>
<li role="presentation">
<a href="#dependencies" aria-controls="dependencies" role="tab" data-toggle="tab">Dependencies</a>
</li>
</ul>
</nav>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="overview">
<table class="table table-striped">
<tr>
<td>Directories</td>
<td class="nummeric"><xsl:value-of select="directories" /></td>
<td class="percent" />
</tr>
<tr>
<td>Files</td>
<td class="nummeric"><xsl:value-of select="files" /></td>
<td class="percent" />
</tr>
</table>
<h2>Size</h2>
<table class="table table-striped">
<tr>
<td>Lines of Code (LOC)</td>
<td class="nummeric"><xsl:value-of select="loc" /></td>
<td/>
</tr>
<tr>
<td>Comment Lines of Code (CLOC)</td>
<td class="nummeric"><xsl:value-of select="cloc" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(cloc div loc * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Non-Comment Lines of Code (NCLOC)</td>
<td class="nummeric"><xsl:value-of select="ncloc" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(ncloc div loc * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Logical Lines of Code (LLOC)</td>
<td class="nummeric"><xsl:value-of select="lloc" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(lloc div loc * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Classes</td>
<td class="nummeric"><xsl:value-of select="llocClasses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(llocClasses div lloc * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Average Class Length</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(classLlocAvg)" /></td>
<td/>
</tr>
<tr>
<td class="indent2">Minimum Class Length</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(classLlocMin)" /></td>
<td/>
</tr>
<tr>
<td class="indent2">Maximum Class Length</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(classLlocMax)" /></td>
<td/>
</tr>
<tr>
<td class="indent">Average Method Length</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(methodLlocAvg)" /></td>
<td/>
</tr>
<tr>
<td class="indent2">Minimum Method Length</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(methodLlocMin)" /></td>
<td/>
</tr>
<tr>
<td class="indent2">Maximum Method Length</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(methodLlocMax)" /></td>
<td/>
</tr>
<tr>
<td>Functions</td>
<td class="nummeric"><xsl:value-of select="llocFunctions" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(llocFunctions div lloc * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Average Function Length</td>
<td class="nummeric"><xsl:value-of select="round(llocByNof)" /></td>
<td/>
</tr>
<tr>
<td>Not in classes or functions</td>
<td class="nummeric"><xsl:value-of select="llocGlobal" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(llocGlobal div lloc * 100,'0.##')" />%)</td>
</tr>
</table>
<h2>Structure</h2>
<table class="table table-striped">
<tr>
<td>Namespaces</td>
<td class="nummeric"><xsl:value-of select="namespaces" /></td>
<td class="percent" />
</tr>
<tr>
<td>Interfaces</td>
<td class="nummeric"><xsl:value-of select="interfaces" /></td>
<td class="percent" />
</tr>
<tr>
<td>Traits</td>
<td class="nummeric"><xsl:value-of select="traits" /></td>
<td class="percent" />
</tr>
<tr>
<td>Classes</td>
<td class="nummeric"><xsl:value-of select="classes" /></td>
<td class="percent" />
</tr>
<tr>
<td class="indent">Abstract Classes</td>
<td class="nummeric"><xsl:value-of select="abstractClasses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(abstractClasses div classes * 100, '0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Concrete Classes</td>
<td class="nummeric"><xsl:value-of select="concreteClasses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(concreteClasses div classes * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Methods</td>
<td class="nummeric"><xsl:value-of select="methods" /></td>
<td class="percent" />
</tr>
<tr>
<td class="indent">Scope</td>
<td class="percent" />
<td class="percent" />
</tr>
<tr>
<td class="indent2">Non-Static Methods</td>
<td class="nummeric"><xsl:value-of select="nonStaticMethods" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(nonStaticMethods div methods * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent2">Static Methods</td>
<td class="nummeric"><xsl:value-of select="staticMethods" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(staticMethods div methods * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Visibility</td>
<td class="percent" />
<td class="percent" />
</tr>
<tr>
<td class="indent2">Public Method</td>
<td class="nummeric"><xsl:value-of select="publicMethods" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(publicMethods div methods * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent2">Non-Public Methods</td>
<td class="nummeric"><xsl:value-of select="nonPublicMethods" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(nonPublicMethods div methods * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Functions</td>
<td class="nummeric"><xsl:value-of select="functions" /></td>
<td class="percent" />
</tr>
<tr>
<td class="indent">Named Functions</td>
<td class="nummeric"><xsl:value-of select="namedFunctions" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(namedFunctions div functions * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Anonymous Functions</td>
<td class="nummeric"><xsl:value-of select="anonymousFunctions" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(anonymousFunctions div functions * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Constants</td>
<td class="nummeric"><xsl:value-of select="constants" /></td>
<td class="percent" />
</tr>
<tr>
<td class="indent">Global Constants</td>
<td class="nummeric"><xsl:value-of select="globalConstants" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(globalConstants div constants * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Class Constants</td>
<td class="nummeric"><xsl:value-of select="classConstants" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(classConstants div constants * 100,'0.##')" />%)</td>
</tr>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="ccn">
<table class="table table-striped">
<tr>
<td>Average Complexity per LLOC</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(ccnByLloc, '0.##')" /></td>
<td class="percent"/>
</tr>
<tr>
<td>Average Complexity per Class</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(classCcnAvg, '0.##')" /></td>
<td class="percent"/>
</tr>
<tr>
<td class="indent">Minimum Class Complexity</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(classCcnMin, '0.##')" /></td>
<td class="percent"/>
</tr>
<tr>
<td class="indent">Maximum Class Complexity</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(classCcnMax, '0.##')" /></td>
<td class="percent"/>
</tr>
<tr>
<td>Average Complexity per Method</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(methodCcnAvg, '0.##')" /></td>
<td class="percent"/>
</tr>
<tr>
<td class="indent">Minimum Method Complexity</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(methodCcnMin, '0.##')" /></td>
<td class="percent"/>
</tr>
<tr>
<td class="indent">Maximum Method Complexity</td>
<td class="nummeric"><xsl:value-of select="phpqa:format-number(methodCcnMax, '0.##')" /></td>
<td class="percent"/>
</tr>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="dependencies">
<table class="table table-striped">
<tr>
<td>Global Accesses</td>
<td class="nummeric"><xsl:value-of select="globalAccesses" /></td>
<td class="percent" />
</tr>
<tr>
<td class="indent">Global Constants</td>
<td class="nummeric"><xsl:value-of select="globalConstantAccesses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(globalConstantAccesses div globalAccesses * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Global Variables</td>
<td class="nummeric"><xsl:value-of select="globalVariableAccesses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(globalVariableAccesses div globalAccesses * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Super-Global Variables</td>
<td class="nummeric"><xsl:value-of select="superGlobalVariableAccesses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(superGlobalVariableAccesses div globalAccesses * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Attribute Accesses</td>
<td class="nummeric"><xsl:value-of select="attributeAccesses" /></td>
<td class="percent" />
</tr>
<tr>
<td class="indent">Non-Static</td>
<td class="nummeric"><xsl:value-of select="instanceAttributeAccesses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(instanceAttributeAccesses div attributeAccesses * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Static</td>
<td class="nummeric"><xsl:value-of select="staticAttributeAccesses" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(staticAttributeAccesses div attributeAccesses * 100,'0.##')" />%)</td>
</tr>
<tr>
<td>Method Calls</td>
<td class="nummeric"><xsl:value-of select="methodCalls" /></td>
<td class="percent" />
</tr>
<tr>
<td class="indent">Non-Static</td>
<td class="nummeric"><xsl:value-of select="instanceMethodCalls" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(instanceMethodCalls div methodCalls * 100,'0.##')" />%)</td>
</tr>
<tr>
<td class="indent">Static</td>
<td class="nummeric"><xsl:value-of select="staticMethodCalls" /></td>
<td class="percent">(<xsl:value-of select="phpqa:format-number(staticMethodCalls div methodCalls * 100,'0.##')" />%)</td>
</tr>
</table>
</div>
</div>
</div>
<script><xsl:attribute name="src"><xsl:value-of select="$jquery.min.js" /></xsl:attribute></script>
<script><xsl:attribute name="src"><xsl:value-of select="$bootstrap.min.js" /></xsl:attribute></script>
</xsl:template>
</xsl:stylesheet>