root/trunk/config/jcoderz-report-filter.xsl

Revision 1319, 10.9 kB (checked in by amandel, 3 years ago)

#2 Quick implementation to detect new findings. The new findings will
get an increased severity level.

  • Property svn:mime-type set to text/xml
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3    $Id$
4
5    Copyright 2006, The jCoderZ.org Project. All rights reserved.
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are
9    met:
10
11        * Redistributions of source code must retain the above copyright
12          notice, this list of conditions and the following disclaimer.
13        * Redistributions in binary form must reproduce the above
14          copyright notice, this list of conditions and the following
15          disclaimer in the documentation and/or other materials
16          provided with the distribution.
17        * Neither the name of the jCoderZ.org Project nor the names of
18          its contributors may be used to endorse or promote products
19          derived from this software without specific prior written
20          permission.
21
22    THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
23    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
26    BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32    ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 -->
34
35<!--
36  This file is maintained by amandel (Andreas Mandel)
37  and mgriffel (Michael Griffel).
38
39  Do not modify this file without approval from
40  the maintainers!
41  -->
42
43<xs:stylesheet xmlns:xs="http://www.w3.org/1999/XSL/Transform"
44   version="1.0">
45
46   <xs:output method="xml"/>
47
48   <xs:template match="*|@*|comment()|text()|processing-instruction()">
49      <xs:copy>
50         <xs:apply-templates select=" *|@*|comment()|text()|processing-instruction()"/>
51      </xs:copy>
52   </xs:template>
53
54   <!-- *** General filters *** -->
55
56    <!-- Never filter samples... -->
57   <xs:template
58       match="/report/file[@package = 'org.jcoderz.phoenix.report.samples']/item"
59       priority="2">
60      <item>
61         <xs:apply-templates select="@*"/>
62         <xs:attribute name="message"><xs:value-of select="concat(@message, ' (sample)')"/></xs:attribute>
63      </item>
64   </xs:template>
65
66   <!-- Some tests are not relevant for testcases....  -->
67   <xs:template
68      match="/report/file[@level = 'test']/
69                     item[@finding-type = 'SignatureDeclareThrowsException'
70                       or @finding-type = 'DE_MIGHT_IGNORE'
71                       or @finding-type = 'EC_UNRELATED_TYPES'
72                       or @finding-type = 'EC_NULL_ARG'
73                       or @finding-type = 'CS_ILLEGAL_CATCH'
74                       or @finding-type = 'EqualsNull'
75                       or @finding-type = 'CouplingBetweenObjects'
76                       or @finding-type = 'ExcessivePublicCount'
77                       or @finding-type = 'CouplingBetweenObjects'
78                       or @finding-type = 'AvoidCatchingNPE']"
79      priority="1">
80      <item>
81         <xs:apply-templates select="@*"/>
82         <xs:attribute name="severity">filtered</xs:attribute>
83         <xs:attribute name="severity-reason">Not required for testcode.</xs:attribute>
84      </item>
85   </xs:template>
86
87   <xs:template
88      match="/report/file[@level = 'test']/item[@severity = 'error']"
89      priority="0">
90      <item>
91         <xs:apply-templates select="@*"/>
92         <xs:attribute name="severity">warning</xs:attribute>
93         <xs:attribute name="severity-reason">Decreased severity from 'error' for testcode.</xs:attribute>
94         <xs:attribute name="message"><xs:value-of select="concat(@message, ' (test code)')"/></xs:attribute>
95      </item>
96   </xs:template>
97
98   <xs:template
99      match="/report/file[@level = 'test']/item[@severity = 'warning']"
100      priority="0">
101      <item>
102         <xs:apply-templates select="@*"/>
103         <xs:attribute name="severity">info</xs:attribute>
104         <xs:attribute name="severity-reason">Decreased severity from 'warning' for testcode.</xs:attribute>
105         <xs:attribute name="message"><xs:value-of select="concat(@message, ' (test code)')"/></xs:attribute>
106      </item>
107   </xs:template>
108
109   <xs:template
110      match="/report/file[@level = 'test']/item[@severity = 'info']"
111      priority="0">
112      <item>
113         <xs:apply-templates select="@*"/>
114         <xs:attribute name="message"><xs:value-of select="concat(@message, ' (test code)')"/></xs:attribute>
115      </item>
116   </xs:template>
117
118   <xs:template
119      match="/report/file[@classname = 'AmountInterface']/
120                   item[@finding-type = 'SuspiciousConstantFieldName']">
121      <item>
122         <xs:apply-templates select="@*"/>
123         <xs:attribute name="severity">filtered</xs:attribute>
124         <xs:attribute name="severity-reason">Constant declared in interface false positive.</xs:attribute>
125      </item>
126   </xs:template>
127
128   <!-- FILTER -->
129   <xs:template
130      match="/report/file/
131                   item[@finding-type = 'EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS']">
132      <item>
133         <xs:apply-templates select="@*"/>
134         <xs:attribute name="severity">info</xs:attribute>
135         <xs:attribute name="severity-reason">Many false positives.</xs:attribute>
136      </item>
137   </xs:template>
138
139   <xs:template
140      match="/report/file[@classname = 'BaseRuntimeException'
141                       or @classname = 'BaseException'
142                       or @classname = 'LogEvent']/
143                   item[@finding-type = 'cpd']">
144      <item>
145         <xs:apply-templates select="@*"/>
146         <xs:attribute name="severity">filtered</xs:attribute>
147         <xs:attribute name="severity-reason">Delegation code can not be externalized further.</xs:attribute>
148      </item>
149   </xs:template>
150
151   <xs:template
152      match="/report/file[@package != 'org.jcoderz.phoenix.report']/
153                   item[@finding-type = 'LSYC_LOCAL_SYNCHRONIZED_COLLECTION']">
154      <item>
155         <xs:apply-templates select="@*"/>
156         <xs:attribute name="severity">filtered</xs:attribute>
157         <xs:attribute name="severity-reason">We are still on Java 1.4 here.</xs:attribute>
158      </item>
159   </xs:template>
160
161   <xs:template
162      match="/report/file[@classname = 'StringUtil']/
163                   item[@finding-type = 'ES_COMPARING_STRINGS_WITH_EQ']">
164      <item>
165         <xs:apply-templates select="@*"/>
166         <xs:attribute name="severity">filtered</xs:attribute>
167         <xs:attribute name="severity-reason">Ok.</xs:attribute>
168      </item>
169   </xs:template>
170
171   <!-- Main type classes. -->
172   <xs:template
173      match="/report/file[@classname = 'DbView'
174                       or @classname = 'SqlTransformer'
175                       or @classname = 'CmpGenerator'
176                       or @classname = 'SqlToXml'
177                       or @classname = 'JavaCodeSnippets'
178                       or @classname = 'LogViewer'
179                       or @classname = 'Chart2DHandlerImpl'
180                       or @classname = 'SqlScanner'
181                       or @classname = 'TemplateZip'
182                       or @classname = 'JDepend']/
183                   item[@finding-type = 'SystemPrintln'
184                     or @finding-type = 'AvoidPrintStackTrace']">
185      <item>
186         <xs:apply-templates select="@*"/>
187         <xs:attribute name="severity">filtered</xs:attribute>
188         <xs:attribute name="severity-reason">main class</xs:attribute>
189      </item>
190   </xs:template>
191
192   <xs:template
193      match="/report/file[@classname = 'StringUtilTest'
194                       or @classname = 'IoUtilTest']/
195                   item[@finding-type = 'UseAssertEqualsInsteadOfAssertTrue']">
196      <item>
197         <xs:apply-templates select="@*"/>
198         <xs:attribute name="severity">filtered</xs:attribute>
199         <xs:attribute name="severity-reason">Ok.</xs:attribute>
200      </item>
201   </xs:template>
202
203   <xs:template
204      match="/report/file[@classname = 'LoggingProxy']/
205                   item[@finding-type = 'MoreThanOneLogger'
206                     or @finding-type = 'LoggerIsNotStaticFinal']">
207      <item>
208         <xs:apply-templates select="@*"/>
209         <xs:attribute name="severity">filtered</xs:attribute>
210         <xs:attribute name="severity-reason">Ok.</xs:attribute>
211      </item>
212   </xs:template>
213
214   <xs:template
215      match="/report/file[@classname = 'AmountBaseTest']/
216                   item[@finding-type = 'CS_MAGIC_NUMBER']">
217      <item>
218         <xs:apply-templates select="@*"/>
219         <xs:attribute name="severity">filtered</xs:attribute>
220         <xs:attribute name="severity-reason">Ok.</xs:attribute>
221      </item>
222   </xs:template>
223
224   <xs:template
225      match="/report/file[@classname = 'LuhnAlgorithm']/
226                   item[@finding-type = 'CS_MAGIC_NUMBER']">
227      <item>
228         <xs:apply-templates select="@*"/>
229         <xs:attribute name="severity">filtered</xs:attribute>
230         <xs:attribute name="severity-reason">Ok for algorithms.</xs:attribute>
231      </item>
232   </xs:template>
233
234   <xs:template
235      match="/report/file[@classname = 'Base64Util'
236                       or @classname = 'Base64UtilTest']/
237                   item[@finding-type = 'CS_MAGIC_NUMBER']">
238      <item>
239         <xs:apply-templates select="@*"/>
240         <xs:attribute name="severity">filtered</xs:attribute>
241         <xs:attribute name="severity-reason">Ok.</xs:attribute>
242      </item>
243   </xs:template>
244
245   <xs:template
246      match="/report/file[@classname = 'Severity'
247                       or @classname = 'TokenType'
248                       or @classname = 'CheckstyleFindingType']/
249                   item[@finding-type = 'CS_DECLARATION_ORDER']">
250      <item>
251         <xs:apply-templates select="@*"/>
252         <xs:attribute name="severity">filtered</xs:attribute>
253         <xs:attribute name="severity-reason">Ok.</xs:attribute>
254      </item>
255   </xs:template>
256
257   <!-- *** Specific false positive *** -->
258   <xs:template
259      match="/report/file[@classname = 'LoggableImpl']/
260              item[@finding-type = 'SE_BAD_FIELD']
261                  [contains(@message, 'mParameters')]">
262      <item>
263         <xs:apply-templates select="@*"/>
264         <xs:attribute name="severity">filtered</xs:attribute>
265         <xs:attribute name="severity-reason">Map implementation is assumed to be always serializable.</xs:attribute>
266      </item>
267   </xs:template>
268
269   <xs:template
270      match="/report/file[@classname = 'LogViewer'][@package = 'org.jcoderz.commons.logging']/
271              item[@finding-type = 'SMII_STATIC_METHOD_INSTANCE_INVOCATION']">
272      <item>
273         <xs:apply-templates select="@*"/>
274         <xs:attribute name="severity">filtered</xs:attribute>
275         <xs:attribute name="severity-reason">Intended use of return value.</xs:attribute>
276      </item>
277   </xs:template>
278
279</xs:stylesheet>
Note: See TracBrowser for help on using the browser.