File: report.py

package info (click to toggle)
cppcheck 1.86-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 14,600 kB
  • sloc: cpp: 169,157; python: 6,329; ansic: 3,848; xml: 847; makefile: 563; sh: 429; cs: 291
file content (57 lines) | stat: -rwxr-xr-x 1,730 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
import os
import re


def hasresult(filename, result):
    if not os.path.isfile(filename):
        return False
    for line in open(filename, 'rt'):
        if result in line:
            return True
    return False


def parsefile(filename):
    ret = []
    linenr = 0
    functionName = None
    for line in open(filename, 'rt'):
        linenr = linenr + 1
        res = re.match('^[a-z]+[ *]+([a-z0-9_]+)[(]', line)
        if res:
            functionName = res.group(1)
        if line.startswith('}'):
            functionName = ''
        elif 'BUG' in line or 'WARN' in line or filename == 'ub.c':
            spaces = ' ' * 100
            s = filename + spaces
            s = s[:15] + str(linenr) + spaces
            s = s[:20] + functionName + spaces
            s = s[:50]
            if hasresult('cppcheck.txt', '[' + filename + ':' + str(linenr) + ']'):
                s = s + '      X'
            else:
                s = s + '       '
            if hasresult('clang.txt', filename + ':' + str(linenr)):
                s = s + '      X'
            else:
                s = s + '       '
            if hasresult('lint.txt', filename + '  ' + str(linenr)):
                s = s + '      X'
            else:
                s = s + '       '
            if hasresult('cov.txt', filename + ':' + str(linenr)):
                s = s + '      X'
            else:
                s = s + '       '
            ret.append(s)
    return ret

bugs = []
bugs.extend(parsefile('controlflow.c'))
bugs.extend(parsefile('data.c'))
bugs.extend(parsefile('functions.c'))
bugs.extend(parsefile('ub.c'))
for bug in bugs:
    print(bug)