From fc46956a083d3dc1e9d2ed1f6e4457bbf7854480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 29 Jun 2018 07:30:20 +0200 Subject: [PATCH] daca2-report: show negatives and positives --- tools/daca2-report.py | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tools/daca2-report.py b/tools/daca2-report.py index 78595fae7..806066694 100644 --- a/tools/daca2-report.py +++ b/tools/daca2-report.py @@ -45,6 +45,54 @@ def summaryHtml(style, font, severity, categories, totalNumber): ret = ret + '\n' return ret +def getWarnings(filename): + ftp = '' + warnings = [] + pattern = re.compile(r'.*: (error|warning|style|performance|portability):.* \[([a-zA-Z0-9_\\-]+)\]') + for line in open(filename, 'rt'): + line = line.strip('\r\n') + if line.startswith('ftp://'): + ftp = line + continue + if pattern.match(line): + warnings.append(ftp + '\n' + line) + return warnings + +def getUnique(warnings1, warnings2): + ret = '' + count = 0 + for w in warnings1: + if w not in warnings2: + ret = ret + w + '\n' + count = count + 1 + return ret, count + +def diffResults(reportpath): + warnings_base = [] + warnings_head = [] + + for lib in ['', 'lib']: + for a in "0123456789abcdefghijklmnopqrstuvwxyz": + if not os.path.isfile(daca2folder + lib + a + '/results-1.84.txt'): + continue + if not os.path.isfile(daca2folder + lib + a + '/results-head.txt'): + continue + + warnings_base.extend(getWarnings(daca2folder + lib + a + '/results-1.84.txt')) + warnings_head.extend(getWarnings(daca2folder + lib + a + '/results-head.txt')) + + f = open(reportpath + 'negatives.txt', 'wt') + s, count_negatives = getUnique(warnings_base, warnings_head) + f.write(s) + f.close() + + f = open(reportpath + 'positives.txt', 'wt') + s, count_positives = getUnique(warnings_base, warnings_head) + f.write(s) + f.close() + + return count_negatives, count_positives + daca2folder = os.path.expanduser('~/daca2/') path = '' for arg in sys.argv[1:]: @@ -57,6 +105,8 @@ for arg in sys.argv[1:]: if path[-1] != '/': path += '/' +count_negatives, count_positives = diffResults(path) + mainpage = open(path + 'daca2.html', 'wt') mainpage.write('\n') mainpage.write('\n') @@ -71,6 +121,8 @@ mainpage.write('

DACA2

\n') mainpage.write('

Results when running latest (git head) Cppcheck on Debian.

\n') mainpage.write('

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.

\n') +mainpage.write('

Negatives: ' + str(count_negatives) + '

\n') +mainpage.write('

Positives: ' + str(count_positives) + '

\n') mainpage.write('\n') mainpage.write( '' +