2017-06-04 22:51:48 +02:00
|
|
|
#!/usr/bin/env python
|
2013-10-16 18:15:51 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2018-02-07 15:38:07 +01:00
|
|
|
import re
|
2013-10-16 18:15:51 +02:00
|
|
|
|
2018-02-13 09:26:11 +01:00
|
|
|
|
2013-10-16 18:15:51 +02:00
|
|
|
def readdate(data):
|
2013-10-18 17:35:59 +02:00
|
|
|
if data[:5] == 'DATE ':
|
|
|
|
datepos = 0
|
|
|
|
else:
|
|
|
|
datepos = data.find('\nDATE ')
|
|
|
|
if datepos >= 0:
|
2017-06-05 13:23:00 +02:00
|
|
|
datepos += 1
|
2013-10-16 18:15:51 +02:00
|
|
|
|
2013-10-18 17:35:59 +02:00
|
|
|
if datepos < 0:
|
|
|
|
return None
|
2013-10-16 18:15:51 +02:00
|
|
|
|
2013-10-18 17:35:59 +02:00
|
|
|
datestr = ''
|
2017-06-05 13:23:00 +02:00
|
|
|
datepos += 5
|
2013-10-18 17:35:59 +02:00
|
|
|
while True:
|
|
|
|
if datepos >= len(data):
|
|
|
|
return None
|
|
|
|
d = data[datepos]
|
2017-07-22 11:05:50 +02:00
|
|
|
if '0' <= d <= '9':
|
2017-06-05 13:23:00 +02:00
|
|
|
datestr += d
|
2015-04-29 17:23:24 +02:00
|
|
|
elif d == '\n' or d == '\r':
|
2013-10-18 17:35:59 +02:00
|
|
|
if len(datestr) == 8:
|
|
|
|
return datestr[:4] + '-' + datestr[4:6] + '-' + datestr[6:]
|
|
|
|
return None
|
|
|
|
elif d != ' ' and d != '-':
|
|
|
|
return None
|
2017-06-05 13:23:00 +02:00
|
|
|
datepos += 1
|
2013-10-16 18:15:51 +02:00
|
|
|
|
2018-02-13 09:26:11 +01:00
|
|
|
|
2018-02-07 20:02:19 +01:00
|
|
|
def summaryHtml(style, font, text1, text2, text3):
|
|
|
|
font1 = ''
|
|
|
|
font2 = ''
|
|
|
|
if font:
|
2018-02-13 09:26:11 +01:00
|
|
|
font1 = font
|
2018-02-07 20:02:19 +01:00
|
|
|
font2 = '</font>'
|
|
|
|
return '<tr> ' +
|
|
|
|
'<td ' + style + '>' + font1 + text1 + font2 + '</td> ' +
|
|
|
|
'<td ' + style + '>' + font1 + text2 + font2 + '</td> ' +
|
|
|
|
'<td ' + style + '>' + font1 + text3 + font2 + '</td> ' +
|
|
|
|
'</tr>\n'
|
|
|
|
|
2017-06-03 11:34:11 +02:00
|
|
|
daca2folder = os.path.expanduser('~/daca2/')
|
|
|
|
path = ''
|
|
|
|
for arg in sys.argv[1:]:
|
|
|
|
if arg.startswith('--daca2='):
|
|
|
|
daca2folder = arg[8:]
|
2017-06-03 12:10:41 +02:00
|
|
|
if daca2folder[-1] != '/':
|
2017-06-05 13:23:00 +02:00
|
|
|
daca2folder += '/'
|
2017-06-03 12:10:41 +02:00
|
|
|
else:
|
2017-06-03 11:34:11 +02:00
|
|
|
path = arg
|
2017-06-03 12:10:41 +02:00
|
|
|
if path[-1] != '/':
|
2017-06-05 13:23:00 +02:00
|
|
|
path += '/'
|
2017-06-03 11:34:11 +02:00
|
|
|
|
|
|
|
mainpage = open(path + 'daca2.html', 'wt')
|
2013-10-17 15:20:58 +02:00
|
|
|
mainpage.write('<!DOCTYPE html>\n')
|
2013-11-04 13:18:01 +01:00
|
|
|
mainpage.write('<html lang="en">\n')
|
|
|
|
mainpage.write('<head>\n')
|
2014-03-16 11:07:40 +01:00
|
|
|
mainpage.write('<meta charset="utf-8">\n')
|
2013-11-04 13:18:01 +01:00
|
|
|
mainpage.write('<title>DACA2</title>\n')
|
2014-03-21 19:36:42 +01:00
|
|
|
mainpage.write('<link rel="stylesheet" href="/site/css/daca2.css">\n')
|
2014-03-16 16:58:48 +01:00
|
|
|
mainpage.write('<script src="/site/js/sorttable.min.js"></script>\n')
|
2013-11-04 13:18:01 +01:00
|
|
|
mainpage.write('</head>\n')
|
2013-10-16 18:15:51 +02:00
|
|
|
mainpage.write('<body>\n')
|
|
|
|
mainpage.write('<h1>DACA2</h1>\n')
|
2014-03-09 08:32:29 +01:00
|
|
|
mainpage.write('<p>Results when running latest (git head) Cppcheck on Debian.</p>\n')
|
2017-06-04 22:51:48 +02:00
|
|
|
mainpage.write('<p>For performance reasons the analysis is limited. Files larger than 1mb are skipped. ' +
|
|
|
|
'If analysis of a file takes more than 10 minutes it may be stopped.</p>\n')
|
2014-03-09 08:32:29 +01:00
|
|
|
mainpage.write('<table class="sortable">\n')
|
2013-11-04 13:18:01 +01:00
|
|
|
mainpage.write(
|
2013-11-24 10:47:12 +01:00
|
|
|
'<tr>' +
|
2014-03-09 08:32:29 +01:00
|
|
|
'<th>Name</th>' +
|
|
|
|
'<th>Date</th>' +
|
|
|
|
'<th>Error</th>' +
|
|
|
|
'<th>Warning</th>' +
|
|
|
|
'<th>Performance</th>' +
|
|
|
|
'<th>Portability</th>' +
|
|
|
|
'<th>Style</th>' +
|
2014-03-12 12:49:06 +01:00
|
|
|
'<th>Crashes</th>' +
|
|
|
|
'<th>VarID 0</th></tr>\n')
|
2013-10-16 18:15:51 +02:00
|
|
|
|
|
|
|
lastupdate = None
|
|
|
|
recent = []
|
|
|
|
|
2018-02-07 15:38:07 +01:00
|
|
|
totalNumber = {}
|
|
|
|
categories = {}
|
|
|
|
for severity in ['error', 'warning', 'style', 'portability', 'performance']:
|
2018-02-07 20:02:19 +01:00
|
|
|
totalNumber[severity] = 0
|
|
|
|
categories[severity] = []
|
2018-02-07 15:38:07 +01:00
|
|
|
|
2017-06-03 11:34:11 +02:00
|
|
|
daca2 = daca2folder
|
2017-06-04 22:51:48 +02:00
|
|
|
for lib in (False, True):
|
2013-10-18 17:35:59 +02:00
|
|
|
for a in "0123456789abcdefghijklmnopqrstuvwxyz":
|
2017-06-04 22:51:48 +02:00
|
|
|
if lib:
|
2013-10-18 17:35:59 +02:00
|
|
|
a = "lib" + a
|
2017-06-03 14:03:16 +02:00
|
|
|
if not os.path.isfile(daca2 + a + '/results.txt'):
|
|
|
|
continue
|
|
|
|
|
|
|
|
f = open(daca2 + a + '/results.txt', 'rt')
|
|
|
|
data = f.read()
|
|
|
|
f.close()
|
|
|
|
|
2017-06-04 22:51:48 +02:00
|
|
|
if 'ftp://' not in data:
|
2017-06-03 14:03:16 +02:00
|
|
|
continue
|
|
|
|
|
|
|
|
datestr = readdate(data)
|
|
|
|
|
|
|
|
if datestr:
|
|
|
|
if not lastupdate or datestr > lastupdate:
|
|
|
|
lastupdate = datestr
|
|
|
|
recent = []
|
|
|
|
if datestr == lastupdate:
|
|
|
|
recent.append(a)
|
|
|
|
else:
|
|
|
|
datestr = ''
|
|
|
|
|
2018-02-07 15:38:07 +01:00
|
|
|
for line in data.split('\n'):
|
|
|
|
res = re.match(r'.*: (error|warning|style|performance|style|portability):.* \[([a-zA-Z0-9_\\-]+)\]', line)
|
|
|
|
if res is None:
|
|
|
|
continue
|
|
|
|
severity = res.group(1)
|
|
|
|
messageId = res.group(2)
|
|
|
|
if messageId == 'cppcheckError':
|
|
|
|
continue
|
|
|
|
if messageId == 'internalAstError':
|
|
|
|
continue
|
|
|
|
if messageId == 'preprocessorErrorDirective':
|
|
|
|
continue
|
|
|
|
if messageId == 'syntaxError':
|
|
|
|
continue
|
|
|
|
totalNumber[severity] = totalNumber[severity] + 1
|
2018-02-13 09:31:05 +01:00
|
|
|
if messageId not in categories[severity]:
|
2018-02-07 15:38:07 +01:00
|
|
|
categories[severity].append(messageId)
|
|
|
|
|
2017-06-03 14:03:16 +02:00
|
|
|
mainpage.write(
|
|
|
|
'<tr>' +
|
|
|
|
'<td><a href="daca2-' + a + '.html">' + a + '</a></td>' +
|
|
|
|
'<td>' + datestr + '</td>' +
|
|
|
|
'<td>' + str(data.count(': error:')) + '</td>' +
|
|
|
|
'<td>' + str(data.count(': warning:')) + '</td>' +
|
|
|
|
'<td>' + str(data.count(': performance:')) + '</td>' +
|
|
|
|
'<td>' + str(data.count(': portability:')) + '</td>' +
|
|
|
|
'<td>' + str(data.count(': style:')) + '</td>' +
|
|
|
|
'<td>' + str(data.count('Crash?')) + '</td>' +
|
|
|
|
'<td>' + str(data.count('with varid 0.')) + '</td>' +
|
|
|
|
'</tr>\n')
|
|
|
|
|
|
|
|
data = data.replace('&', '&')
|
|
|
|
data = data.replace('<', '<')
|
|
|
|
data = data.replace('>', '>')
|
|
|
|
data = data.replace('\n', '\n')
|
|
|
|
|
|
|
|
f = open(path + 'daca2-' + a + '.html', 'wt')
|
|
|
|
f.write('<!DOCTYPE html>\n')
|
|
|
|
f.write('<html lang="en">\n')
|
|
|
|
f.write('<head>\n')
|
|
|
|
f.write('<meta charset="utf-8">\n')
|
|
|
|
f.write('<title>DACA2 - ' + a + '</title>\n')
|
|
|
|
f.write('</head>\n')
|
|
|
|
f.write('<body>\n')
|
|
|
|
f.write('<h1>DACA2 - ' + a + '</h1>')
|
|
|
|
f.write('<pre>\n' + data + '</pre>\n')
|
|
|
|
f.write('</body>\n')
|
|
|
|
f.write('</html>\n')
|
|
|
|
f.close()
|
2013-10-16 18:15:51 +02:00
|
|
|
|
2013-11-04 13:18:01 +01:00
|
|
|
mainpage.write('</table>\n')
|
|
|
|
|
2018-02-07 15:38:07 +01:00
|
|
|
mainpage.write('<b>Summary</b>\n')
|
|
|
|
mainpage.write('<table>\n')
|
2018-02-07 20:02:19 +01:00
|
|
|
mainpage.write(summaryHtml('style="background-color:#369"', '<font style="color:#eee">', 'Severity', 'Types', 'Amount'))
|
|
|
|
mainpage.write(summaryHtml('style="background-color:#fff"', None, 'Error (there is bug)', categories['error'], totalNumber['error']))
|
|
|
|
mainpage.write(summaryHtml('style="background-color:#ccccff"', None, 'Warning (potential bug)', categories['warning'], totalNumber['warning']))
|
|
|
|
mainpage.write(summaryHtml('style="background-color:#fff"', None, 'Style', categories['style'], totalNumber['style']))
|
|
|
|
mainpage.write(summaryHtml('style="background-color:#ccccff"', None, 'Portability', categories['portability'], totalNumber['portability']))
|
|
|
|
mainpage.write(summaryHtml('style="background-color:#fff"', None, 'Performance', categories['performance'], totalNumber['performance']))
|
2018-02-07 15:38:07 +01:00
|
|
|
mainpage.write('</table>\n')
|
|
|
|
|
2013-10-16 18:15:51 +02:00
|
|
|
if lastupdate:
|
2013-10-18 17:35:59 +02:00
|
|
|
mainpage.write('<p>Last update: ' + lastupdate + '</p>')
|
|
|
|
allrecent = ''
|
|
|
|
for r in recent:
|
2013-12-15 12:33:06 +01:00
|
|
|
allrecent = allrecent + ' <a href="daca2-' + r + '.html">' + r + '</a>'
|
|
|
|
mainpage.write('<p>Most recently updated:' + allrecent + '</p>')
|
2013-10-16 18:15:51 +02:00
|
|
|
|
|
|
|
mainpage.write('</body>\n')
|
|
|
|
mainpage.write('</html>\n')
|