triage: write number of fp/tp in report

This commit is contained in:
Daniel Marjamäki 2015-01-06 19:35:15 +01:00
parent d72fbdda27
commit ad8af6b24e
1 changed files with 17 additions and 6 deletions

View File

@ -22,18 +22,15 @@ fin = open(resultfile,'rt')
results = fin.read() results = fin.read()
fin.close() fin.close()
fout = open('report.html','wt')
fout.write('<html><head><title>Cppcheck results for ' + project + '</title><link rel="stylesheet" type="text/css" href="theme1.css"></head><body>\n')
fout.write('<h1>Cppcheck results for ' + project + '</h1>\n')
fout.write('<table border="0">\n')
fout.write('<tr><th>Filename</th><th>Line</th><th>Message</th><th>Classification</th></tr>\n')
out = {} out = {}
out['untriaged'] = '' out['untriaged'] = ''
out['fp'] = '' out['fp'] = ''
out['tp'] = '' out['tp'] = ''
out['notfound'] = '' out['notfound'] = ''
numberOfFalsePositives = 0
numberOfTruePositives = 0
for result in results.split('\n'): for result in results.split('\n'):
result = result.strip() result = result.strip()
@ -49,9 +46,11 @@ for result in results.split('\n'):
if result in truepositives: if result in truepositives:
css = 'tp' css = 'tp'
classification = 'Bug' classification = 'Bug'
numberOfTruePositives += 1
elif result in falsepositives: elif result in falsepositives:
css = 'fp' css = 'fp'
classification = 'Not bug' classification = 'Not bug'
numberOfFalsePositives += 1
href = None href = None
html = ' <tr>' html = ' <tr>'
@ -98,7 +97,19 @@ for line in f.readlines():
f.close(); f.close();
project2 = ''
if project.find('-') > 0:
project2 = project[:project.find('-')]
else:
project2 = project
fout = open('report.html','wt')
fout.write('<html><head><title>Cppcheck results for ' + project + '</title><link rel="stylesheet" type="text/css" href="theme1.css"></head><body>\n')
fout.write('<h1>Cppcheck results for ' + project + '</h1>\n')
fout.write('<p>Number of true positives: ' + str(numberOfTruePositives) + '</p>\n')
fout.write('<p>Number of false positives: ' + str(numberOfFalsePositives) + '</p>\n')
fout.write('<table border="0">\n')
fout.write('<tr><th>Filename</th><th>Line</th><th>Message</th><th>Classification</th></tr>\n')
fout.write(out['tp']) fout.write(out['tp'])
fout.write(out['notfound']) fout.write(out['notfound'])
fout.write(out['untriaged']) fout.write(out['untriaged'])