"Fossies" - the Fresh Open Source Software Archive

Member "cppcheck-1.89/test/synthetic/report.py" (1 Sep 2019, 1673 Bytes) of package /windows/misc/cppcheck-1.89.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env python
    2 import os
    3 import re
    4 
    5 
    6 def hasresult(filename, result):
    7     if not os.path.isfile(filename):
    8         return False
    9     for line in open(filename, 'rt'):
   10         if result in line:
   11             return True
   12     return False
   13 
   14 
   15 def parsefile(filename):
   16     ret = []
   17     linenr = 0
   18     functionName = None
   19     for line in open(filename, 'rt'):
   20         linenr = linenr + 1
   21         res = re.match('^[a-z]+[ *]+([a-z0-9_]+)[(]', line)
   22         if res:
   23             functionName = res.group(1)
   24         if line.startswith('}'):
   25             functionName = ''
   26         elif 'BUG' in line or 'WARN' in line or filename == 'ub.c':
   27             spaces = ' ' * 100
   28             s = filename + spaces
   29             s = s[:15] + str(linenr) + spaces
   30             s = s[:20] + functionName + spaces
   31             s = s[:50]
   32             if hasresult('cppcheck.txt', '[' + filename + ':' + str(linenr) + ']'):
   33                 s = s + '      X'
   34             else:
   35                 s = s + '       '
   36             if hasresult('clang.txt', filename + ':' + str(linenr)):
   37                 s = s + '      X'
   38             else:
   39                 s = s + '       '
   40             if hasresult('lint.txt', filename + '  ' + str(linenr)):
   41                 s = s + '      X'
   42             else:
   43                 s = s + '       '
   44             if hasresult('cov.txt', filename + ':' + str(linenr)):
   45                 s = s + '      X'
   46             else:
   47                 s = s + '       '
   48             ret.append(s)
   49     return ret
   50 
   51 bugs = []
   52 bugs.extend(parsefile('controlflow.c'))
   53 bugs.extend(parsefile('data.c'))
   54 bugs.extend(parsefile('functions.c'))
   55 bugs.extend(parsefile('ub.c'))
   56 for bug in bugs:
   57     print(bug)