Skip to content

Commit 4a8631f

Browse files
committed
(GH-2) Additional StyleCop Configuration
- Controlling the output of the XML file for StyleCop, one for each project - Added XSL file for making an output HTML file
1 parent cbeaff9 commit 4a8631f

File tree

4 files changed

+172
-0
lines changed

4 files changed

+172
-0
lines changed

BuildScripts/StyleCop.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<StyleCopOutputFile>..\..\BuildArtifacts\StyleCopReport.$(AssemblyName).$(Platform).$(Configuration).xml</StyleCopOutputFile>
5+
<StyleCopForceFullAnalysis>true</StyleCopForceFullAnalysis>
6+
</PropertyGroup>
7+
</Project>

BuildScripts/StyleCopReport.xsl

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3+
<xsl:output method="html"/>
4+
<xsl:variable name="stylecop.root" select="//StyleCopViolations"/>
5+
6+
<xsl:template match="/">
7+
<div name="StyleCopViolations">
8+
9+
<script language="javascript">
10+
<![CDATA[
11+
function expcol (sender, args){
12+
13+
var el = document.getElementById (args);
14+
if (el.style.display == 'block') {
15+
el.style.display = 'none';
16+
} else {
17+
el.style.display = 'block';
18+
}
19+
20+
tootleText(sender);
21+
for(var index = 2; index < arguments.length; index++){
22+
var elem = document.getElementById (arguments[index]);
23+
tootleText(elem);
24+
}
25+
26+
}
27+
28+
function tootleText(elem){
29+
if ('[show]' == elem.textContent){
30+
elem.textContent = '[hide]';
31+
}else if ('[hide]' == elem.textContent){
32+
elem.textContent = '[show]';
33+
}
34+
}
35+
]]>
36+
</script>
37+
38+
<style type="text/css">
39+
li { line-height: 1.5em; padding-bottom: 5px;}
40+
*[name=missingInfo] { font-weight: bold;}
41+
div[name=StyleCopViolations] .sectionheader { width: 98%; padding: 2px;}
42+
.toc { background-color: #F6F6F6;
43+
border: 1px solid #DDDDDD;
44+
padding: 10px;
45+
margin-right: 10px;
46+
float: right;
47+
width: 400px;
48+
overflow: hidden;
49+
}
50+
div[name=StyleCopViolations] h2 { font-size: 1.2em;}
51+
52+
div[name=StyleCopViolations] a { text-decoration: none;}
53+
div[name=StyleCopViolations] a:hover { text-decoration: underline; color: red;}
54+
.ruleBlock { background-color: #f6f6f6; border: solid 1px #dddddd;}
55+
.fileInfo {font-weight: bold;}
56+
.description { color: #60376F;}
57+
</style>
58+
59+
<div class="sectionheader">StyleCop Report</div>
60+
<xsl:choose>
61+
<xsl:when test="count($stylecop.root) = 0">
62+
<span name="missingInfo">No StyleCop information in build logs.</span>
63+
</xsl:when>
64+
</xsl:choose>
65+
<xsl:apply-templates select="$stylecop.root"/>
66+
</div>
67+
</xsl:template>
68+
69+
<xsl:template match="StyleCopViolations">
70+
71+
<div name="header">
72+
73+
<h1>StyleCop Report</h1>
74+
75+
<span name="label">
76+
<xsl:choose>
77+
<xsl:when test="count(./Violation) > 0">
78+
<xsl:attribute name="class">error</xsl:attribute>
79+
</xsl:when>
80+
<xsl:otherwise>
81+
<xsl:attribute name="class">success</xsl:attribute>
82+
</xsl:otherwise>
83+
</xsl:choose>
84+
<a name="summary"></a>
85+
There were <xsl:value-of select="count(./Violation)" /> violations found, breaking
86+
<xsl:value-of select="count(Violation[not(@Rule=preceding::Violation/@Rule)])" /> rules in
87+
<xsl:value-of select="count(Violation[not(@Source=preceding::Violation/@Source)])" /> files
88+
</span>
89+
90+
<!-- TOC -->
91+
<div class="toc">
92+
<div align="center">
93+
<b style="font-size: 10pt;">Table of contents</b>
94+
</div>
95+
<p style="font-size: 10pt;">
96+
<a href="#summary">1.&#160;&#160;Summary</a>
97+
<br />
98+
&#160;&#160;<a href="#toogleListOfRules" onclick="expcol(this, 'listOfRules', 'toogleListOfRules');">1.1.&#160;&#160;Rule violations per file report</a>
99+
<br />
100+
<a href="#mainreport">2.&#160;&#160;Reported rule violations</a>
101+
<br />
102+
<xsl:for-each select="Violation/@Rule[not(.=preceding::Violation/@Rule)]">
103+
<xsl:sort select="." />
104+
<xsl:variable name="rule">
105+
<xsl:value-of select="." />
106+
</xsl:variable>
107+
&#160;&#160;<a href="#{$rule}">2.<xsl:value-of select="position()" />.&#160;<xsl:value-of select="$rule" /><br />
108+
</a>
109+
</xsl:for-each>
110+
</p>
111+
</div>
112+
113+
<!-- List of violations per file -->
114+
<h2 id="filesDetails">Rule violations per file report
115+
<a href="#" id="toogleListOfRules" onclick="expcol(this, 'listOfRules'); return false;">[show]</a>
116+
</h2>
117+
<br />
118+
<div id="listOfRules" style="display:none;">
119+
<ul >
120+
<xsl:for-each select="Violation[not(@Source=preceding::Violation/@Source)]">
121+
<xsl:sort select="./@Source" />
122+
<xsl:variable name="filePath">
123+
<xsl:value-of select="./@Source" />
124+
</xsl:variable>
125+
<li><xsl:value-of select="@Source" /> : <xsl:value-of select="count(//Violation[@Source=$filePath])" /> violation(s)</li>
126+
</xsl:for-each>
127+
</ul>
128+
<a href="#filesDetails" onclick="expcol(this, 'listOfRules', 'toogleListOfRules');">[Hide details per file]</a>
129+
</div>
130+
</div>
131+
132+
<!-- List of violations per rule -->
133+
<h2><a name="mainreport"></a>Reported rule violations</h2>
134+
<ol name="errorList">
135+
<xsl:for-each select="Violation[not(@Rule=preceding::Violation/@Rule)]">
136+
<xsl:sort select="@Rule" />
137+
<xsl:variable name="rule">
138+
<xsl:value-of select="./@Rule" />
139+
</xsl:variable>
140+
<h3><xsl:value-of select="position()" />.&#160;<xsl:value-of select="@Rule" />&#160;
141+
<a href="#" onclick="expcol(this, 'ruleDetails{$rule}'); return false;"><xsl:attribute name="name"><xsl:value-of select="./@Rule" /></xsl:attribute>[hide]</a>
142+
</h3>
143+
<div id="ruleDetails{$rule}" style="display:block;" >
144+
145+
<h4><xsl:value-of select="count(//Violation[@Rule=$rule])" /> violation(s) found</h4>
146+
147+
<ol class="ruleBlock">
148+
<xsl:for-each select="//Violation[@Rule=$rule]">
149+
<xsl:sort select="@Source" />
150+
<xsl:sort select="@LineNumber" />
151+
<li>
152+
<span class="fileInfo"><xsl:value-of select="concat(@Source, ' : ', @LineNumber)" /></span><br/>
153+
<span class="description"><xsl:value-of select="." /></span>
154+
</li>
155+
</xsl:for-each>
156+
</ol>
157+
</div>
158+
</xsl:for-each>
159+
</ol>
160+
</xsl:template>
161+
162+
</xsl:stylesheet>
163+

src/App/ReleaseNotesCompiler.CLI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ foreach (var item in filesToCleanup)
122122
<Import Project="..\packages\GitVersionTask.1.2.0\Build\GitVersionTask.targets" Condition="Exists('..\packages\GitVersionTask.1.2.0\Build\GitVersionTask.targets')" />
123123
<Import Project="..\packages\NuGetPackager.0.1.3\build\NuGetPackager.targets" Condition="Exists('..\packages\NuGetPackager.0.1.3\build\NuGetPackager.targets')" />
124124
<Import Project="..\packages\Fody.1.26.1\build\Fody.targets" Condition="Exists('..\packages\Fody.1.26.1\build\Fody.targets')" />
125+
<Import Project="..\..\BuildScripts\StyleCop.props" Condition="Exists('..\..\BuildScripts\StyleCop.props')" />
125126
<Import Project="..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets" Condition="Exists('..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" />
126127
<Import Project="..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets" Condition="Exists('..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets')" />
127128
</Project>

src/Compiler/ReleaseNotesCompiler.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
</Target>
7777
<Import Project="..\packages\GitVersionTask.1.2.0\Build\GitVersionTask.targets" Condition="Exists('..\packages\GitVersionTask.1.2.0\Build\GitVersionTask.targets')" />
7878
<Import Project="..\packages\Fody.1.26.1\build\Fody.targets" Condition="Exists('..\packages\Fody.1.26.1\build\Fody.targets')" />
79+
<Import Project="..\..\BuildScripts\StyleCop.props" Condition="Exists('..\..\BuildScripts\StyleCop.props')" />
7980
<Import Project="..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets" Condition="Exists('..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" />
8081
<Import Project="..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets" Condition="Exists('..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets')" />
8182
</Project>

0 commit comments

Comments
 (0)