66
|
1 |
"{ Package: 'stx:goodies/builder/reports' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Builder }"
|
|
4 |
|
|
5 |
ReportFormat subclass:#LintReportFormat
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Builder-Reports-Formats'
|
|
10 |
!
|
|
11 |
|
|
12 |
LintReportFormat subclass:#CheckStyle
|
|
13 |
instanceVariableNames:''
|
|
14 |
classVariableNames:''
|
|
15 |
poolDictionaries:''
|
|
16 |
privateIn:LintReportFormat
|
|
17 |
!
|
|
18 |
|
|
19 |
LintReportFormat subclass:#PMD
|
|
20 |
instanceVariableNames:''
|
|
21 |
classVariableNames:''
|
|
22 |
poolDictionaries:''
|
|
23 |
privateIn:LintReportFormat
|
|
24 |
!
|
|
25 |
|
|
26 |
|
|
27 |
!LintReportFormat class methodsFor:'testing'!
|
|
28 |
|
|
29 |
isAbstract
|
|
30 |
|
|
31 |
^self == LintReportFormat
|
|
32 |
|
|
33 |
"Created: / 04-08-2011 / 11:44:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
34 |
! !
|
|
35 |
|
253
|
36 |
!LintReportFormat methodsFor:'writing'!
|
|
37 |
|
|
38 |
writeSource: source to: sourceFilename
|
|
39 |
(report outputDirectory / sourceFilename) writingFileDo:[ :s |
|
|
40 |
source fileOutOn: s
|
|
41 |
].
|
|
42 |
|
|
43 |
"Created: / 07-10-2011 / 10:19:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
44 |
"Modified: / 15-12-2014 / 11:19:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
45 |
! !
|
|
46 |
|
66
|
47 |
!LintReportFormat::CheckStyle class methodsFor:'accessing'!
|
|
48 |
|
|
49 |
symbolicNames
|
|
50 |
"Returns a collection of symbolic names for this format"
|
|
51 |
|
|
52 |
^#(checkstyle)
|
|
53 |
|
|
54 |
"Modified: / 04-08-2011 / 14:23:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
55 |
! !
|
|
56 |
|
|
57 |
!LintReportFormat::CheckStyle methodsFor:'accessing - defaults'!
|
|
58 |
|
|
59 |
defaultFileSuffix
|
|
60 |
|
|
61 |
^ 'xml'
|
|
62 |
|
|
63 |
"Modified: / 08-10-2011 / 10:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!LintReportFormat::CheckStyle methodsFor:'writing'!
|
|
67 |
|
|
68 |
writeFile: filename with: block
|
|
69 |
|
|
70 |
"Writes a section for given file"
|
|
71 |
|
|
72 |
stream tab; nextPutAll:'<file name="'; nextPutAll:filename; nextPutAll: '">'; cr.
|
|
73 |
block valueWithOptionalArgument: self.
|
|
74 |
stream tab; nextPutAll:'</file>'; cr.
|
|
75 |
|
|
76 |
"Created: / 07-10-2011 / 10:40:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
77 |
!
|
|
78 |
|
|
79 |
writeFooter
|
|
80 |
|
|
81 |
stream nextPutAll: '</checkstyle>'
|
|
82 |
|
|
83 |
"Modified: / 04-08-2011 / 14:42:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
84 |
!
|
|
85 |
|
|
86 |
writeHeader
|
|
87 |
|
|
88 |
stream nextPutAll: '<?xml version="1.0" encoding="UTF-8"?>'; nextPut: Character lf.
|
|
89 |
stream nextPutAll: '<checkstyle version="5.4">'; nextPut: Character lf.
|
|
90 |
|
|
91 |
"Modified: / 06-10-2011 / 23:50:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
92 |
!
|
|
93 |
|
|
94 |
writeViolation:rule class: aClass selector: aSelector startLine:line column:column stopLine:lineStop column:columnStop
|
|
95 |
|
|
96 |
| severity |
|
|
97 |
|
|
98 |
rule severity = #information ifTrue:[
|
|
99 |
severity := 'info'
|
|
100 |
] ifFalse:[
|
|
101 |
rule severity = #warning ifTrue:[
|
|
102 |
severity := 'warning'
|
|
103 |
] ifFalse:[
|
|
104 |
severity := 'error'
|
|
105 |
]
|
|
106 |
].
|
|
107 |
|
|
108 |
stream tab; tab; nextPutAll:'<error'.
|
|
109 |
stream nextPutAll:' source="'; nextPutAll:(self encode:rule class name); nextPut:$".
|
|
110 |
stream nextPutAll:' message="'; nextPutAll:(self encode:rule name ); nextPut:$".
|
|
111 |
|
|
112 |
stream nextPutAll:' severity="'; nextPutAll: severity; nextPut:$".
|
|
113 |
stream nextPutAll:' line="'; nextPutAll:line printString; nextPut:$".
|
|
114 |
column <= 1 ifFalse:[
|
|
115 |
stream nextPutAll:' column="'; nextPutAll:column printString; nextPut:$"
|
|
116 |
].
|
|
117 |
stream nextPutAll:'/>'; cr.
|
|
118 |
|
|
119 |
"Created: / 25-11-2011 / 22:23:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
120 |
! !
|
|
121 |
|
|
122 |
!LintReportFormat::PMD methodsFor:'accessing - defaults'!
|
|
123 |
|
|
124 |
defaultFileSuffix
|
|
125 |
|
|
126 |
^ 'xml'
|
|
127 |
|
|
128 |
"Modified: / 08-10-2011 / 10:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
129 |
! !
|
|
130 |
|
|
131 |
!LintReportFormat::PMD methodsFor:'writing'!
|
|
132 |
|
|
133 |
writeFile: filename with: block
|
|
134 |
|
|
135 |
"Writes a section for given file"
|
|
136 |
|
|
137 |
stream tab; nextPutAll:'<file name="'; nextPutAll:filename; nextPutAll: '">'; cr.
|
|
138 |
block valueWithOptionalArgument: self.
|
|
139 |
stream tab; nextPutAll:'</file>'; cr.
|
|
140 |
|
|
141 |
"Created: / 07-10-2011 / 10:40:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
142 |
!
|
|
143 |
|
|
144 |
writeFooter
|
|
145 |
|
|
146 |
stream nextPutAll: '</pmd>'
|
|
147 |
|
|
148 |
"Modified: / 25-11-2011 / 19:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
149 |
!
|
|
150 |
|
|
151 |
writeHeader
|
|
152 |
|
|
153 |
stream nextPutAll: '<?xml version="1.0" encoding="UTF-8"?>'; nextPut: Character lf.
|
|
154 |
stream
|
|
155 |
nextPutAll: '<pmd version="4.3" timestamp="';
|
|
156 |
nextPutAll: Timestamp now printString;
|
|
157 |
nextPutAll:'">';
|
|
158 |
nextPut: Character lf.
|
|
159 |
|
|
160 |
"Modified: / 25-11-2011 / 19:39:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
161 |
!
|
|
162 |
|
|
163 |
writeViolation:rule class: aClass selector: aSelector startLine:beginLine column:beginColumn stopLine:endLine column:endColumn
|
|
164 |
|
|
165 |
| priority |
|
|
166 |
|
|
167 |
rule severity = #information ifTrue:[
|
|
168 |
priority := '1'
|
|
169 |
] ifFalse:[
|
|
170 |
rule severity = #warning ifTrue:[
|
|
171 |
priority := '2'
|
|
172 |
] ifFalse:[
|
|
173 |
priority := '3'
|
|
174 |
]
|
|
175 |
].
|
|
176 |
|
|
177 |
stream nextPutAll:'<violation '.
|
|
178 |
|
|
179 |
stream nextPutAll:'beginline="';nextPutAll: beginLine printString; nextPut:$"; cr.
|
|
180 |
stream nextPutAll:'begincolumn="';nextPutAll: beginColumn printString; nextPut:$"; cr.
|
|
181 |
stream nextPutAll:'endline="';nextPutAll: endLine printString; nextPut:$"; cr.
|
|
182 |
stream nextPutAll:'endcolumn="';nextPutAll: endColumn printString; nextPut:$"; cr.
|
|
183 |
|
|
184 |
stream nextPutAll:'rule="';nextPutAll: (self encode:rule class name); nextPut:$"; cr.
|
|
185 |
stream nextPutAll:'ruleset="';nextPutAll: (self encode:rule group); nextPut:$"; cr.
|
|
186 |
|
|
187 |
stream nextPutAll:'package="';nextPutAll: aClass package; nextPut:$"; cr.
|
|
188 |
stream nextPutAll:'class="';nextPutAll: aClass name; nextPut:$"; cr.
|
|
189 |
|
|
190 |
aSelector notNil ifTrue:[
|
|
191 |
stream nextPutAll:'method="';nextPutAll: aSelector; nextPut:$"; cr.
|
|
192 |
].
|
|
193 |
|
|
194 |
stream nextPutAll:'><!![CDATA['; cr.
|
|
195 |
stream nextPutAll: (self encode: rule rationale); cr.
|
|
196 |
stream nextPutAll:']]></violation>'; cr; cr.
|
|
197 |
stream flush.
|
|
198 |
|
|
199 |
"Created: / 25-11-2011 / 22:28:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
200 |
! !
|
|
201 |
|
|
202 |
!LintReportFormat class methodsFor:'documentation'!
|
|
203 |
|
|
204 |
version
|
|
205 |
^ '$Header$'
|
|
206 |
!
|
|
207 |
|
|
208 |
version_CVS
|
|
209 |
^ '$Header$'
|
|
210 |
!
|
|
211 |
|
|
212 |
version_SVN
|
253
|
213 |
^ '$Id$'
|
66
|
214 |
! !
|
253
|
215 |
|