daca2-report: tweaked diff report

This commit is contained in:
Daniel Marjamäki 2018-07-01 14:59:38 +02:00
parent 8c228c6ced
commit bb73a741a8
1 changed files with 46 additions and 26 deletions

View File

@ -48,31 +48,57 @@ def summaryHtml(style, font, severity, categories, totalNumber):
def getWarnings(filename): def getWarnings(filename):
ftp = '' ftp = ''
warnings = {} warnings = {}
warnings[''] = []
pattern = re.compile(r'(.*:[0-9]+):[0-9]+: (error|warning|style|performance|portability)(:.* \[[a-zA-Z0-9_\\-]+\])') pattern = re.compile(r'(.*:[0-9]+):[0-9]+: (error|warning|style|performance|portability)(:.* \[[a-zA-Z0-9_\\-]+\])')
for line in open(filename, 'rt'): for line in open(filename, 'rt'):
line = line.strip('\r\n') line = line.strip('\r\n')
if line.startswith('ftp://'): if line.startswith('ftp://'):
ftp = line ftp = line
warnings[ftp] = []
continue continue
res = pattern.match(line) res = pattern.match(line)
if res: if res:
warnings[ftp + '\n' + res.group(1) + ': ' + res.group(2) + res.group(3)] = 1 warnings[ftp].append(res.group(1) + ': ' + res.group(2) + res.group(3))
return warnings return warnings
def getUnique(warnings1, warnings2): def diffWarnings(warnings1, warnings2):
ret = '' ret = ''
count = 0 count1 = 0
for w in warnings1.keys(): count2 = 0
if w not in warnings2: for ftp in warnings1.keys():
ret = ret + w + '\n' if len(ftp)<4:
count = count + 1 continue
return ret, count w1 = sorted(warnings1[ftp])
w2 = sorted(warnings2[ftp])
i1 = 0
i2 = 0
while i1 < len(w1) and i2 < len(w2):
if w1[i1] == w2[i2]:
i1 = i1 + 1
i2 = i2 + 1
elif w1[i1] < w2[i2]:
ret = ret + '1.84: ' + w1[i1] + '\n'
count1 = count1 + 1
i1 = i1 + 1
else:
ret = ret + 'head: ' + w2[i2] + '\n'
count2 = count2 + 1
i2 = i2 + 1
while i1 < len(w1):
ret = ret + '1.84: ' + w1[i1] + '\n'
count1 = count1 + 1
i1 = i1 + 1
while i2 < len(w2):
ret = ret + 'head: ' + w2[i2] + '\n'
count2 = count2 + 1
i2 = i2 + 1
return ret, count1, count2
def diffResults(reportpath): def diffResults(reportpath):
negatives = '' diff = ''
count_negatives = 0 count_negatives = 0
positives = ''
count_positives = 0 count_positives = 0
for lib in ['', 'lib']: for lib in ['', 'lib']:
@ -87,20 +113,13 @@ def diffResults(reportpath):
warnings_base = getWarnings(daca2folder + lib + a + '/results-1.84.txt') warnings_base = getWarnings(daca2folder + lib + a + '/results-1.84.txt')
warnings_head = getWarnings(daca2folder + lib + a + '/results-head.txt') warnings_head = getWarnings(daca2folder + lib + a + '/results-head.txt')
s, count = getUnique(warnings_base, warnings_head) s, count1, count2 = diffWarnings(warnings_base, warnings_head)
negatives += s diff = diff + s
count_negatives += count count_negatives += count1
count_positives += count2
s, count = getUnique(warnings_head, warnings_base) f = open(reportpath + 'diff.txt', 'wt')
positives += s f.write(diff)
count_positives += count
f = open(reportpath + 'negatives.txt', 'wt')
f.write(negatives)
f.close()
f = open(reportpath + 'positives.txt', 'wt')
f.write(positives)
f.close() f.close()
return count_negatives, count_positives return count_negatives, count_positives
@ -133,8 +152,9 @@ mainpage.write('<h1>DACA2</h1>\n')
mainpage.write('<p>Results when running latest (git head) Cppcheck on Debian.</p>\n') mainpage.write('<p>Results when running latest (git head) Cppcheck on Debian.</p>\n')
mainpage.write('<p>For performance reasons the analysis is limited. Files larger than 1mb are skipped. ' + 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') 'If analysis of a file takes more than 10 minutes it may be stopped.</p>\n')
mainpage.write('<p>Negatives (fixed/lost warnings): <a href="negatives.txt">' + str(count_negatives) + '</a></p>\n')
mainpage.write('<p>Positives (new warnings): <a href="positives.txt">' + str(count_positives) + '</a></p>\n') mainpage.write('<p>Show <a href="diff.txt">diff</a> (1.84:' + str(count_negatives) + ', head:' + str(count_positives) + ')</p>\n')
mainpage.write('<table class="sortable">\n') mainpage.write('<table class="sortable">\n')
mainpage.write( mainpage.write(
'<tr>' + '<tr>' +