forked from plone/buildout.jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins-code-analysis.cfg
351 lines (324 loc) · 12.7 KB
/
jenkins-code-analysis.cfg
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
# -----------------------------------------------------------------------------
# JENKINS BUILDOUT FOR CODE ANALYSIS
# -----------------------------------------------------------------------------
# This buildout needs to be extended by overriding the
# jenkins-test-directories variable. See README.txt for more details.
# -----------------------------------------------------------------------------
[buildout]
parts +=
pep8-bin
pep8
pyflakes-bin
pyflakes
ohcount-bin
ohcount
clonedigger-bin
clonedigger
zptlint-bin
zptlint
xmllint
i18ndude
i18ndude-bin
jenkins-code-analysis
jenkins-directory = ${buildout:directory}/parts/jenkins-test
# This value needs to be overridden in the buildout file that extends this
# buildout.
jenkins-test-directories =
# -----------------------------------------------------------------------------
# PEP 8 CODE ANALYSIS
# -----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis-pep8" script in the bin directory of the
# buildout that runs a PEP 8 code analysis and outputs the results in a
# pep8.log file that the Jenkins violations plugin can process.
# -----------------------------------------------------------------------------
[pep8-bin]
recipe = zc.recipe.egg
eggs =
pep8
entry-points = pep8-bin=pep8:_main
[pep8]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
if [ -s ${buildout:jenkins-directory}/pep8.log ]; then
rm ${buildout:jenkins-directory}/pep8.log
echo "Removing old pep8.log file"
fi
if [ -s ${buildout:jenkins-directory}/pep8.log.tmp ]; then
rm ${buildout:jenkins-directory}/pep8.log.tmp
fi
echo "Start PEP 8 code analysis:"
PACKAGES="${buildout:jenkins-test-directories}"
for pkg in $PACKAGES
do
echo "Analyse $pkg"
find -L ${buildout:directory}/$pkg -regex ".*\.py" | xargs -r bin/pep8-bin >> ${buildout:jenkins-directory}/pep8.log.tmp
done
cat ${buildout:jenkins-directory}/pep8.log.tmp|sed 's:${buildout:directory}/::' > ${buildout:jenkins-directory}/pep8.log
echo "Finished."
echo ""
output = ${buildout:directory}/bin/jenkins-code-analysis-pep8
mode = 755
# -----------------------------------------------------------------------------
# PYFLAKES CODE ANALYSIS
# -----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis-pyflakes" script in the bin directory of the
# buildout that runs a PyFlakes code analyisis and outputs the results in
# a pyflakes.log file that the Jenkins warnings plugin can process.
# -----------------------------------------------------------------------------
[pyflakes-bin]
recipe = zc.recipe.egg
eggs =
pyflakes
entry-points = pyflakes-bin=pyflakes.scripts.pyflakes:main
[pyflakes]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
if [ -s ${buildout:jenkins-directory}/pyflakes.log ]; then
rm ${buildout:jenkins-directory}/pyflakes.log
echo "Removing old pyflakes.log file"
fi
if [ -s ${buildout:jenkins-directory}/pyflakes.log.tmp ]; then
rm ${buildout:jenkins-directory}/pyflakes.log.tmp
fi
echo "Start PyFlakes code analysis:"
PACKAGES="${buildout:jenkins-test-directories}"
for pkg in $PACKAGES
do
echo "Analyse $pkg"
find -L $pkg -regex ".*\.py" | xargs -r bin/pyflakes-bin >> ${buildout:jenkins-directory}/pyflakes.log.tmp
done
cat ${buildout:jenkins-directory}/pyflakes.log.tmp|sed 's:${buildout:directory}/::' > ${buildout:jenkins-directory}/pyflakes.log
echo "Finished."
echo ""
output = ${buildout:directory}/bin/jenkins-code-analysis-pyflakes
mode = 755
# -----------------------------------------------------------------------------
# PYLINT CODE ANALYSIS
# -----------------------------------------------------------------------------
# XXX: Commented out for now. Pylint consumes just too much resources.
#[pylint-bin]
#recipe = zc.recipe.egg
#eggs = logilab.pylintinstaller
#extra-paths = ${instance:location}/lib/python
#entry-points = pylint-bin=pylint.lint:Run
#arguments = sys.argv[1:]
#arguments = [
# '--output-format=parseable',
# '--zope=y',
# '--reports=y',
# '--disable-msg=E0611,F0401,W0232,E1101,C0103,C0111,R0201,W0201,R0911,R0904#,F0220,E1103,R0901,E0211,E0213,E1002,W0622',
# '--generated-members=objects',
# ] + sys.argv[1:]
# Disable messages:
#
# E0611: No name %r in module %r. Used when a name cannot be found in a module.
# F0401: Unable to import %r (%s). Used when pylint has been unable to import a module.
# W0232: Class has no __init__ method. Used when a class has no __init__ method, neither its parent classes.
# C0103: Invalid name "%s" (should match %s). Used when the name doesn't match the regular expression associated to its type (constant, variable, class...).
# C0111: Message Missing docstring Description Used when a module, function, class or method has no docstring. Some special methods like init don't necessary require a docstring. Explanation…
# R0201: Method could be a function
# W0201: Attribute %r defined outside __init__
# R0911: Too many return statements (%s/%s)
# E0211: Method has no argument
# - Reason: raises an error on zope.interface definitions
# E0213 Method should have "self" as first argument
# - Reason: raises an error on zope.interface definitions
# E1121 Too many positional arguments for function call
# - Reason: ???
# E1002 Use super on an old style class
# - Reason: super(CommentsViewlet, self).update() raises an error
# W0622 total_comments: Redefining built-in 'object'
# - Reason: top level def function will not work (e.g. for catalog indexers)
# ...
# See http://pylint-messages.wikidot.com/all-messages for a full list.
#
#
#[pylint]
#recipe = collective.recipe.template
#input = inline:
# #!/bin/sh
# if [ -s pylint.log ]; then
# rm pylint.log
# echo "Removing old pylint.log file"
# fi
# echo "Start pylint"
# PACKAGES="${buildout:jenkins-test-directories}"
# for pkg in $PACKAGES
# do
# echo "Running pylint for $pkg"
# find -L $pkg -regex ".*\.py" | xargs bin/pylint >> pylint.log
# done
# echo "finish"
#output = ${buildout:directory}/bin/jenkins-code-analysis-pylint
#mode = 755
# -----------------------------------------------------------------------------
# CLONEDIGGER CODE ANALYSIS
# -----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis-clonedigger" script in the bin directory of
# the buildout...TODO
# -----------------------------------------------------------------------------
[clonedigger-bin]
recipe = zc.recipe.egg
eggs =
clonedigger
[clonedigger]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
echo "Start CloneDigger code analysis:"
clonedigger --cpd-output -o ${buildout:jenkins-directory}/clonedigger.xml ${buildout:directory}/src
echo "Finished."
echo ""
output = ${buildout:directory}/bin/jenkins-code-analysis-clonedigger
mode = 755
# ----------------------------------------------------------------------------
# OHCOUNT
# ----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis-ohcount" script in the bin directory of the
# buildout that runs, ohcount, a source code line counter. This requires
# ohcount to be installed on the server (see
# http://pypi.python.org/pypi/ohconvert for more information.)
# The results can be included into Jenkins with the SLOCCount plugin:
# https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin
# ----------------------------------------------------------------------------
[ohcount-bin]
recipe = zc.recipe.egg
eggs = ohconvert
[ohcount]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
if [ -s ${buildout:jenkins-directory}/sloccount.sc ]; then
rm ${buildout:jenkins-directory}/sloccount.sc
echo "Removing old sloccount.sc file"
fi
echo "Start OHCount code analysis:"
PACKAGES="${buildout:jenkins-test-directories}"
for pkg in $PACKAGES
do
echo "Analyse $pkg"
${buildout:directory}/bin/ohconvert $pkg >> ${buildout:jenkins-directory}/sloccount.sc
done
echo "Finished."
echo ""
output = ${buildout:directory}/bin/jenkins-code-analysis-ohcount
mode = 755
# -----------------------------------------------------------------------------
# XML LINT CODE ANALYSIS
# -----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis-xmllint" script in the bin directory of the
# buildout. This requires xmllint to be installed on the system.
# -----------------------------------------------------------------------------
[xmllint]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
if [ ! -e /usr/bin/xmllint ]; then
echo "XML Lint can not be found in /usr/bin/xmllint. Please make sure xmllint is installed."
exit 1
fi
if [ -e ${buildout:jenkins-directory}/xmllint.log ]; then
echo "Removing existing xmllint.log file"
rm ${buildout:jenkins-directory}/xmllint.log
fi
echo "Start XMLLint code analysis:"
PACKAGES="${buildout:jenkins-test-directories}"
for pkg in $PACKAGES
do
echo "Analyse $pkg"
find -L $pkg -regex ".*\.[cz]?pt" | xargs xmllint --noout > ${buildout:jenkins-directory}/xmllint.log 2>&1
done
if [ -s ${buildout:jenkins-directory}/xmllint.log ]; then
echo "Errors were found:"
cat ${buildout:jenkins-directory}/xmllint.log
echo "Errors were written to xmllint.log"
exit 1;
else
echo "No errors found"
fi
echo "Finished."
echo ""
output = ${buildout:directory}/bin/jenkins-code-analysis-xmllint
mode = 755
# -----------------------------------------------------------------------------
# ZPT LINT CODE ANALYSIS
# -----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis-zptlint" script in the bin directory of the
# buildout...TODO
# -----------------------------------------------------------------------------
[zptlint-bin]
recipe = zc.recipe.egg
eggs =
zptlint
entry-points = zptlint-bin=zptlint:run
[zptlint]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
if [ -e ${buildout:jenkins-directory}/zptlint.log ]; then
echo "Old zptlint.log file removed"
rm ${buildout:jenkins-directory}/zptlint.log
fi
echo "Start ZPTLint code analysis:"
PACKAGES="${buildout:jenkins-test-directories}"
for pkg in $PACKAGES
do
echo "Analyse $pkg"
find -L $pkg -regex ".*\.[cz]?pt" | xargs -r bin/zptlint-bin >> ${buildout:jenkins-directory}/zptlint.log
done
echo "Finished."
echo ""
output = ${buildout:directory}/bin/jenkins-code-analysis-zptlint
mode = 755
# -----------------------------------------------------------------------------
# TRANSLATION CODE ANALYSIS
# -----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis-translations" script in the bin directory
# of the buildout that runs a code analysis on all templates to find
# untranslated strings.
# -----------------------------------------------------------------------------
[i18ndude-bin]
recipe = zc.recipe.egg
eggs =
i18ndude
entry-points = i18ndude-bin=zptlint:run
[i18ndude]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
#!/bin/sh
if [ -e ${buildout:jenkins-directory}/i18ndude.log ]; then
echo "Old i18ndude.log file removed"
rm ${buildout:jenkins-directory}/i18ndude.log
fi
echo "Start translations code analysis:"
PACKAGES="${buildout:jenkins-test-directories}"
for pkg in $PACKAGES
do
echo "Analyse $pkg"
find -L $pkg -regex ".*\.[cz]?pt" | xargs -r bin/i18ndude find-untranslated -s >> ${buildout:jenkins-directory}/i18ndude.log
done
echo "Finished."
echo ""
output = ${buildout:directory}/bin/jenkins-code-analysis-translations
mode = 755
# -----------------------------------------------------------------------------
# CODE ANALYSIS
# -----------------------------------------------------------------------------
# Creates a "jenkins-code-analysis" script in the bin directory of the buildout
# that runs all code analysis sections at once.
# -----------------------------------------------------------------------------
[jenkins-code-analysis]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
bin/jenkins-code-analysis-pep8
bin/jenkins-code-analysis-pyflakes
bin/jenkins-code-analysis-ohcount
bin/jenkins-code-analysis-xmllint
bin/jenkins-code-analysis-zptlint
bin/jenkins-code-analysis-translations
output = ${buildout:directory}/bin/jenkins-code-analysis
mode = 755