forked from uncas/icrawl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSourceMonitor-Top15Generation.xsl
139 lines (124 loc) · 5.8 KB
/
SourceMonitor-Top15Generation.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
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--- SourceMonitor Summary Xml File Generation created by Eden Ridgway -->
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:apply-templates select="/sourcemonitor_metrics" />
</xsl:template>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:variable name="spaces">
<xsl:text> </xsl:text>
</xsl:variable>
<!-- Transform the results into a simpler more intuitive and summarised format -->
<xsl:template match="sourcemonitor_metrics">
<xsl:copy-of select="$newline" />
<SourceMonitorComplexitySummary>
<xsl:copy-of select="$newline" />
<MostComplexMethods>
<xsl:copy-of select="$newline" />
<xsl:call-template name="MostComplexMethods"/>
</MostComplexMethods>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$newline" />
<MostDeeplyNestedCode>
<xsl:copy-of select="$newline" />
<xsl:call-template name="MostDeeplyNestedCode"/>
</MostDeeplyNestedCode>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$newline" />
<MostLines>
<xsl:copy-of select="$newline" />
<xsl:call-template name="MostLines"/>
</MostLines>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$newline" />
<MostMethods>
<xsl:copy-of select="$newline" />
<xsl:call-template name="MostMethods"/>
</MostMethods>
<xsl:copy-of select="$newline" />
</SourceMonitorComplexitySummary>
<xsl:copy-of select="$newline" />
</xsl:template>
<!-- Complexity Metrics -->
<xsl:template name="MostComplexMethods">
<xsl:for-each select=".//file">
<xsl:sort select="metrics/metric[@id='M10']" order="descending" data-type="number" />
<xsl:choose>
<xsl:when test="position() < 16">
<xsl:copy-of select="$spaces" /><Method>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><File><xsl:value-of select="@file_name"/></File>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Name><xsl:value-of select="metrics/metric[@id='M9']"/></Name>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Line><xsl:value-of select="metrics/metric[@id='M8']"/></Line>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Complexity><xsl:value-of select="metrics/metric[@id='M10']"/></Complexity>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /></Method>
<xsl:copy-of select="$newline" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- Nesting Metrics -->
<xsl:template name="MostDeeplyNestedCode">
<xsl:for-each select=".//file">
<xsl:sort select="metrics/metric[@id='M12']" order="descending" data-type="number" />
<xsl:choose>
<xsl:when test="position() < 16">
<xsl:copy-of select="$spaces" /><Block>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><File><xsl:value-of select="@file_name"/></File>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Depth><xsl:value-of select="metrics/metric[@id='M12']"/></Depth>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Line><xsl:value-of select="metrics/metric[@id='M11']"/></Line>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /></Block>
<xsl:copy-of select="$newline" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- Line count Metrics -->
<xsl:template name="MostLines">
<xsl:for-each select=".//file">
<xsl:sort select="metrics/metric[@id='M0']" order="descending" data-type="number" />
<xsl:choose>
<xsl:when test="position() < 16">
<xsl:copy-of select="$spaces" /><File>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Name><xsl:value-of select="@file_name"/></Name>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Lines><xsl:value-of select="metrics/metric[@id='M0']"/></Lines>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /></File>
<xsl:copy-of select="$newline" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- Method count Metrics -->
<xsl:template name="MostMethods">
<xsl:for-each select=".//file">
<xsl:sort select="metrics/metric[@id='M5']" order="descending" data-type="number" />
<xsl:choose>
<xsl:when test="position() < 16">
<xsl:copy-of select="$spaces" /><File>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Name><xsl:value-of select="@file_name"/></Name>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /><xsl:copy-of select="$spaces" /><Methods><xsl:value-of select="metrics/metric[@id='M5']"/></Methods>
<xsl:copy-of select="$newline" />
<xsl:copy-of select="$spaces" /></File>
<xsl:copy-of select="$newline" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>