PEP8 fixes.

[ci skip]
This commit is contained in:
XhmikosR 2014-07-21 17:10:04 +03:00
parent bdc024bd7c
commit c090ed2fc9
7 changed files with 276 additions and 256 deletions

View File

@ -275,15 +275,17 @@ class AnnotateCodeFormatter(HtmlFormatter):
if error['line'] == line_no: if error['line'] == line_no:
try: try:
if error['inconclusive'] == 'true': if error['inconclusive'] == 'true':
if error.get('verbose') and (error['verbose'] != error['msg']): # only print verbose msg if it really differs from actual message # only print verbose msg if it really differs
# from actual message
if error.get('verbose') and (error['verbose'] != error['msg']):
index = t.rfind('\n') index = t.rfind('\n')
t = t[:index] + HTML_EXPANDABLE_INCONCLUSIVE % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index+1:] t = t[:index] + HTML_EXPANDABLE_INCONCLUSIVE % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index + 1:]
else: else:
t = t.replace('\n', HTML_INCONCLUSIVE % error['msg']) t = t.replace('\n', HTML_INCONCLUSIVE % error['msg'])
except KeyError: except KeyError:
if error.get('verbose') and (error['verbose'] != error['msg']): if error.get('verbose') and (error['verbose'] != error['msg']):
index = t.rfind('\n') index = t.rfind('\n')
t = t[:index] + HTML_EXPANDABLE_ERROR % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index+1:] t = t[:index] + HTML_EXPANDABLE_ERROR % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index + 1:]
else: else:
t = t.replace('\n', HTML_ERROR % error['msg']) t = t.replace('\n', HTML_ERROR % error['msg'])
@ -521,7 +523,7 @@ if __name__ == '__main__':
except IndexError: except IndexError:
cnt_min = 0 cnt_min = 0
for occurrences in reversed(range(cnt_min, cnt_max+1)): for occurrences in reversed(range(cnt_min, cnt_max + 1)):
for _id in [k for k, v in sorted(Counter(stats).items()) if v == occurrences]: for _id in [k for k, v in sorted(Counter(stats).items()) if v == occurrences]:
stat_html.append(" " + str(dict(Counter(stats).most_common())[_id]) + " " + str(_id) + "<br/>\n") stat_html.append(" " + str(dict(Counter(stats).most_common())[_id]) + " " + str(_id) + "<br/>\n")
@ -584,14 +586,13 @@ if __name__ == '__main__':
'w') as css_file: 'w') as css_file:
css_file.write(STYLE_FILE) css_file.write(STYLE_FILE)
print("Creating stats.html (statistics)\n") print("Creating stats.html (statistics)\n")
stats_countlist={} stats_countlist = {}
for filename, data in sorted(files.items()): for filename, data in sorted(files.items()):
if (filename == ''): if (filename == ''):
continue continue
stats_tmplist=[] stats_tmplist = []
for error in sorted(data['errors'], key=lambda k: k['line']): for error in sorted(data['errors'], key=lambda k: k['line']):
stats_tmplist.append(error['severity']) stats_tmplist.append(error['severity'])
@ -607,37 +608,39 @@ if __name__ == '__main__':
for sev in SEVERITIES: for sev in SEVERITIES:
_sum = 0 _sum = 0
stats_templist={} stats_templist = {}
try: # if the we have an style warning but we are checking for portability, we have to skip it to prevent KeyError # if the we have an style warning but we are checking for
# portability, we have to skip it to prevent KeyError
try:
for filename in stats_countlist: for filename in stats_countlist:
try: # also bail out if we have a file with no sev-results try: # also bail out if we have a file with no sev-results
_sum += stats_countlist[filename][sev] _sum += stats_countlist[filename][sev]
stats_templist[filename] = (int)(stats_countlist[filename][sev]) # file : amount, stats_templist[filename] = (int)(stats_countlist[filename][sev]) # file : amount,
except KeyError: except KeyError:
continue continue
if (_sum == 0): # don't print "0 style" etc, if no style warnings were found # don't print "0 style" etc, if no style warnings were found
if (_sum == 0):
break break
except KeyError: except KeyError:
continue continue
stats_file.write("<p>Top 10 files for " + sev + " severity, total findings: " + str(_sum) + "</br>\n") stats_file.write("<p>Top 10 files for " + sev + " severity, total findings: " + str(_sum) + "</br>\n")
# sort, so that the file with the most severities per type is first # sort, so that the file with the most severities per type is first
stats_list_sorted = sorted(stats_templist.items(), key=operator.itemgetter(1,0), reverse=True) stats_list_sorted = sorted(stats_templist.items(), key=operator.itemgetter(1, 0), reverse=True)
it = 0 it = 0
LENGTH = 0 LENGTH = 0
for i in stats_list_sorted: # printing loop for i in stats_list_sorted: # printing loop
# for aesthetics: if it's the first iteration of the loop, get the max length of the number string # for aesthetics: if it's the first iteration of the loop, get
# the max length of the number string
if (it == 0): if (it == 0):
LENGTH = len(str(i[1])) # <- length of longest number, now get the difference and try to make other numbers align to it LENGTH = len(str(i[1])) # <- length of longest number, now get the difference and try to make other numbers align to it
stats_file.write("&#160;"*3 + str(i[1]) + "&#160;"*(1 + LENGTH - len(str(i[1]))) + "<a href=\"" + files[i[0]]['htmlfile'] + "\"> " + i[0] + "</a></br>\n") stats_file.write("&#160;" * 3 + str(i[1]) + "&#160;" * (1 + LENGTH - len(str(i[1]))) + "<a href=\"" + files[i[0]]['htmlfile'] + "\"> " + i[0] + "</a></br>\n")
it += 1 it += 1
if (it == 10): # print only the top 10 if (it == 10): # print only the top 10
break break
stats_file.write("</p>\n") stats_file.write("</p>\n")
print("\nOpen '" + options.report_dir + "/index.html' to see the results.") print("\nOpen '" + options.report_dir + "/index.html' to see the results.")

View File

@ -32,6 +32,8 @@ def upload(file_to_upload, destination):
pass pass
# git push # git push
def gitpush(): def gitpush():
try: try:
password = sys.argv[1] password = sys.argv[1]

View File

@ -3,51 +3,52 @@
from lxml import etree from lxml import etree
class Token: class Token:
Id = None Id = None
str = None str = None
next = None next = None
previous = None previous = None
scopeId = None scopeId = None
scope = None scope = None
isName = None isName = None
isNumber = None isNumber = None
isInt = None isInt = None
isFloat = None isFloat = None
isString = None isString = None
strlen = None strlen = None
isChar = None isChar = None
isOp = None isOp = None
isArithmeticalOp = None isArithmeticalOp = None
isAssignmentOp = None isAssignmentOp = None
isComparisonOp = None isComparisonOp = None
isLogicalOp = None isLogicalOp = None
linkId = None linkId = None
link = None link = None
varId = None varId = None
variableId = None variableId = None
variable = None variable = None
functionId = None functionId = None
function = None function = None
valuesId = None valuesId = None
values = None values = None
astParentId = None astParentId = None
astParent = None astParent = None
astOperand1Id = None astOperand1Id = None
astOperand1 = None astOperand1 = None
astOperand2Id = None astOperand2Id = None
astOperand2 = None astOperand2 = None
file = None file = None
linenr = None linenr = None
def __init__(self, element): def __init__(self, element):
self.Id = element.get('id') self.Id = element.get('id')
self.str = element.get('str') self.str = element.get('str')
self.next = None self.next = None
self.previous = None self.previous = None
self.scopeId = element.get('scope') self.scopeId = element.get('scope')
self.scope = None self.scope = None
type = element.get('type') type = element.get('type')
if type == 'name': if type == 'name':
self.isName = True self.isName = True
elif type == 'number': elif type == 'number':
@ -71,37 +72,37 @@ class Token:
self.isComparisonOp = True self.isComparisonOp = True
elif element.get('isLogicalOp'): elif element.get('isLogicalOp'):
self.isLogicalOp = True self.isLogicalOp = True
self.linkId = element.get('link') self.linkId = element.get('link')
self.link = None self.link = None
self.varId = element.get('varId') self.varId = element.get('varId')
self.variableId = element.get('variable') self.variableId = element.get('variable')
self.variable = None self.variable = None
self.functionId = element.get('function') self.functionId = element.get('function')
self.function = None self.function = None
self.valuesId = element.get('values') self.valuesId = element.get('values')
self.values = None self.values = None
self.astParentId = element.get('astParent') self.astParentId = element.get('astParent')
self.astParent = None self.astParent = None
self.astOperand1Id = element.get('astOperand1') self.astOperand1Id = element.get('astOperand1')
self.astOperand1 = None self.astOperand1 = None
self.astOperand2Id = element.get('astOperand2') self.astOperand2Id = element.get('astOperand2')
self.astOperand2 = None self.astOperand2 = None
self.file = element.get('file') self.file = element.get('file')
self.linenr = element.get('linenr') self.linenr = element.get('linenr')
def setId(self, IdMap): def setId(self, IdMap):
self.scope = IdMap[self.scopeId] self.scope = IdMap[self.scopeId]
self.link = IdMap[self.linkId] self.link = IdMap[self.linkId]
self.variable = IdMap[self.variableId] self.variable = IdMap[self.variableId]
self.function = IdMap[self.functionId] self.function = IdMap[self.functionId]
self.values = IdMap[self.valuesId] self.values = IdMap[self.valuesId]
self.astParent = IdMap[self.astParentId] self.astParent = IdMap[self.astParentId]
self.astOperand1 = IdMap[self.astOperand1Id] self.astOperand1 = IdMap[self.astOperand1Id]
self.astOperand2 = IdMap[self.astOperand2Id] self.astOperand2 = IdMap[self.astOperand2Id]
# Get value if it exists # Get value if it exists
# Returns None if it doesn't exist # Returns None if it doesn't exist
def getValue(self,v): def getValue(self, v):
if not self.values: if not self.values:
return None return None
for value in self.values: for value in self.values:
@ -109,110 +110,120 @@ class Token:
return value return value
return None return None
class Scope:
Id = None
classStartId = None
classStart = None
classEndId = None
classEnd = None
className = None
type = None
def __init__(self,element): class Scope:
self.Id = element.get('id') Id = None
self.className = element.get('className') classStartId = None
classStart = None
classEndId = None
classEnd = None
className = None
type = None
def __init__(self, element):
self.Id = element.get('id')
self.className = element.get('className')
self.classStartId = element.get('classStart') self.classStartId = element.get('classStart')
self.classStart = None self.classStart = None
self.classEndId = element.get('classEnd') self.classEndId = element.get('classEnd')
self.classEnd = None self.classEnd = None
self.nestedInId = element.get('nestedId') self.nestedInId = element.get('nestedId')
self.nestedIn = None self.nestedIn = None
self.type = element.get('type') self.type = element.get('type')
def setId(self, IdMap): def setId(self, IdMap):
self.classStart = IdMap[self.classStartId] self.classStart = IdMap[self.classStartId]
self.classEnd = IdMap[self.classEndId] self.classEnd = IdMap[self.classEndId]
self.nestedIn = IdMap[self.nestedInId] self.nestedIn = IdMap[self.nestedInId]
class Function: class Function:
Id = None Id = None
argument = None argument = None
argumentId = None argumentId = None
def __init__(self,element):
self.Id = element.get('id') def __init__(self, element):
self.argument = {} self.Id = element.get('id')
self.argument = {}
self.argumentId = {} self.argumentId = {}
for arg in element: for arg in element:
self.argumentId[arg.get('nr')] = arg.get('id') self.argumentId[arg.get('nr')] = arg.get('id')
def setId(self, IdMap): def setId(self, IdMap):
for argnr, argid in self.argumentId.items(): for argnr, argid in self.argumentId.items():
self.argument[argnr] = IdMap[argid] self.argument[argnr] = IdMap[argid]
class Variable: class Variable:
Id = None Id = None
nameTokenId = None nameTokenId = None
nameToken = None nameToken = None
typeStartTokenId = None typeStartTokenId = None
typeStartToken = None typeStartToken = None
typeEndTokenId = None typeEndTokenId = None
typeEndToken = None typeEndToken = None
isArgument = None isArgument = None
isArray = None isArray = None
isClass = None isClass = None
isLocal = None isLocal = None
isPointer = None isPointer = None
isReference = None isReference = None
isStatic = None isStatic = None
def __init__(self, element): def __init__(self, element):
self.Id = element.get('id') self.Id = element.get('id')
self.nameTokenId = element.get('nameToken') self.nameTokenId = element.get('nameToken')
self.nameToken = None self.nameToken = None
self.typeStartTokenId = element.get('typeStartToken') self.typeStartTokenId = element.get('typeStartToken')
self.typeStartToken = None self.typeStartToken = None
self.typeEndTokenId = element.get('typeEndToken') self.typeEndTokenId = element.get('typeEndToken')
self.typeEndToken = None self.typeEndToken = None
self.isArgument = element.get('isArgument') self.isArgument = element.get('isArgument')
self.isArray = element.get('isArray') self.isArray = element.get('isArray')
self.isClass = element.get('isClass') self.isClass = element.get('isClass')
self.isLocal = element.get('isLocal') self.isLocal = element.get('isLocal')
self.isPointer = element.get('isPointer') self.isPointer = element.get('isPointer')
self.isReference = element.get('isReference') self.isReference = element.get('isReference')
self.isStatic = element.get('isStatic') self.isStatic = element.get('isStatic')
def setId(self, IdMap): def setId(self, IdMap):
self.nameToken = IdMap[self.nameTokenId] self.nameToken = IdMap[self.nameTokenId]
self.typeStartToken = IdMap[self.typeStartTokenId] self.typeStartToken = IdMap[self.typeStartTokenId]
self.typeEndToken = IdMap[self.typeEndTokenId] self.typeEndToken = IdMap[self.typeEndTokenId]
class ValueFlow: class ValueFlow:
class Value: class Value:
intvalue = None intvalue = None
condition = None condition = None
def __init__(self, element): def __init__(self, element):
self.intvalue = int(element.get('intvalue')) self.intvalue = int(element.get('intvalue'))
self.condition = element.get('condition-line') self.condition = element.get('condition-line')
if self.condition: if self.condition:
self.condition = int(self.condition) self.condition = int(self.condition)
Id = None Id = None
values = None values = None
def __init__(self, element): def __init__(self, element):
self.Id = element.get('id') self.Id = element.get('id')
self.values = [] self.values = []
for value in element: for value in element:
self.values.append(ValueFlow.Value(value)) self.values.append(ValueFlow.Value(value))
class CppcheckData: class CppcheckData:
tokenlist = [] tokenlist = []
scopes = [] scopes = []
functions = [] functions = []
variables = [] variables = []
valueflow = [] valueflow = []
def __init__(self, filename): def __init__(self, filename):
self.tokenlist = [] self.tokenlist = []
self.scopes = [] self.scopes = []
self.variables = [] self.variables = []
self.valueflow = [] self.valueflow = []
@ -245,7 +256,7 @@ class CppcheckData:
IdMap = {} IdMap = {}
IdMap[None] = None IdMap[None] = None
IdMap['0'] = None IdMap['0'] = None
for token in self.tokenlist: for token in self.tokenlist:
IdMap[token.Id] = token IdMap[token.Id] = token
for scope in self.scopes: for scope in self.scopes:
@ -266,10 +277,13 @@ class CppcheckData:
for variable in self.variables: for variable in self.variables:
variable.setId(IdMap) variable.setId(IdMap)
def parsedump(filename): def parsedump(filename):
return CppcheckData(filename) return CppcheckData(filename)
# Check if type of ast node is float/double # Check if type of ast node is float/double
def astIsFloat(token): def astIsFloat(token):
if not token: if not token:
return False return False
@ -283,7 +297,7 @@ def astIsFloat(token):
# float literal? # float literal?
if token.str[0].isdigit(): if token.str[0].isdigit():
for c in token.str: for c in token.str:
if c=='f' or c=='.' or c=='E': if c == 'f' or c == '.' or c == 'E':
return True return True
return False return False
typeToken = token.variable.typeStartToken typeToken = token.variable.typeStartToken

View File

@ -125,6 +125,7 @@ def removeLargeFiles(path):
elif g[-2:] != '.C' and g[-2:] != '.c' and g[-4:] != '.cc' and g[-4:] != '.cpp' and g[-4:] != '.cxx' and g[-2:] != '.h' and g[-2:] != '.H' and g[-4:] != '.c++' and g[-4:] != '.hpp' and g[-4:] != '.tpp' and g[-4:] != '.t++': elif g[-2:] != '.C' and g[-2:] != '.c' and g[-4:] != '.cc' and g[-4:] != '.cpp' and g[-4:] != '.cxx' and g[-2:] != '.h' and g[-2:] != '.H' and g[-4:] != '.c++' and g[-4:] != '.hpp' and g[-4:] != '.tpp' and g[-4:] != '.t++':
os.remove(g) os.remove(g)
def downloadpackage(filepath, outpath): def downloadpackage(filepath, outpath):
# remove all files/folders # remove all files/folders
removeAll() removeAll()

View File

@ -146,7 +146,7 @@ def scanarchive(filepath, jobs):
# #
# List of skipped packages - which trigger known yet unresolved problems with cppcheck. # List of skipped packages - which trigger known yet unresolved problems with cppcheck.
# The issues on trac (http://trac.cppcheck.net) are given for reference # The issues on trac (http://trac.cppcheck.net) are given for reference
# boost #3654 (?) # boost #3654 (?)
# flite #5975 # flite #5975
# insight#5184 # insight#5184

View File

@ -2,123 +2,123 @@
import glob import glob
import os import os
def checknonnull(cfg, functionName, nonnull):
pos1 = cfg.find('<function name="' + functionName + '">')
if pos1 < 0:
return
pos2 = cfg.find('</function>', pos1)
if pos2 < 0:
return
functionCfg = cfg[pos1:pos2]
s = None
for argnr in range(10):
argpos1 = functionCfg.find('<arg nr="'+str(argnr)+'">')
if argpos1 < 0:
continue
argpos2 = functionCfg.find('</arg>', argpos1)
notnullpos = functionCfg.find('not-null', argpos1)
if notnullpos > 0 and notnullpos < argpos2:
if s:
s = s + ', ' + str(argnr)
else:
s = str(argnr)
if s != nonnull:
if not nonnull:
nonnull = ''
if not s:
s = ''
print(functionName + '\tglibc:' + nonnull + '\tcfg:' + s)
def checknonnull(cfg, functionName, nonnull):
pos1 = cfg.find('<function name="' + functionName + '">')
if pos1 < 0:
return
pos2 = cfg.find('</function>', pos1)
if pos2 < 0:
return
functionCfg = cfg[pos1:pos2]
s = None
for argnr in range(10):
argpos1 = functionCfg.find('<arg nr="' + str(argnr) + '">')
if argpos1 < 0:
continue
argpos2 = functionCfg.find('</arg>', argpos1)
notnullpos = functionCfg.find('not-null', argpos1)
if notnullpos > 0 and notnullpos < argpos2:
if s:
s = s + ', ' + str(argnr)
else:
s = str(argnr)
if s != nonnull:
if not nonnull:
nonnull = ''
if not s:
s = ''
print(functionName + '\tglibc:' + nonnull + '\tcfg:' + s)
def parseheader(cppcheckpath, filename): def parseheader(cppcheckpath, filename):
f = open(filename,'rt') f = open(filename, 'rt')
data = f.read() data = f.read()
f.close() f.close()
f = open(cppcheckpath + '/cfg/std.cfg', 'rt') f = open(cppcheckpath + '/cfg/std.cfg', 'rt')
stdcfg = f.read() stdcfg = f.read()
f.close() f.close()
f = open(cppcheckpath + '/cfg/posix.cfg', 'rt') f = open(cppcheckpath + '/cfg/posix.cfg', 'rt')
posixcfg = f.read() posixcfg = f.read()
f.close() f.close()
while data.find('/*') >= 0: while data.find('/*') >= 0:
pos1 = data.find('/*') pos1 = data.find('/*')
pos2 = data.find('*/', pos1+2) pos2 = data.find('*/', pos1 + 2)
data = data[:pos1] + data[pos2+2:] data = data[:pos1] + data[pos2 + 2:]
data = data.replace('\\\n', '') data = data.replace('\\\n', '')
while data.find('\n#') >= 0: while data.find('\n#') >= 0:
pos1 = data.find('\n#') pos1 = data.find('\n#')
pos2 = data.find('\n', pos1+1) pos2 = data.find('\n', pos1 + 1)
data = data[:pos1] + data[pos2:] data = data[:pos1] + data[pos2:]
while data.find('\n__BEGIN') >= 0: while data.find('\n__BEGIN') >= 0:
pos1 = data.find('\n__BEGIN') pos1 = data.find('\n__BEGIN')
pos2 = data.find('\n', pos1 + 1) pos2 = data.find('\n', pos1 + 1)
data = data[:pos1] + data[pos2:] data = data[:pos1] + data[pos2:]
while data.find('\n__END') >= 0: while data.find('\n__END') >= 0:
pos1 = data.find('\n__END') pos1 = data.find('\n__END')
pos2 = data.find('\n', pos1 + 1) pos2 = data.find('\n', pos1 + 1)
data = data[:pos1] + data[pos2:] data = data[:pos1] + data[pos2:]
data = data.replace('\n\n', '\n') data = data.replace('\n\n', '\n')
data = data.replace('\t', ' ') data = data.replace('\t', ' ')
data = data.replace(',\n ', ',') data = data.replace(',\n ', ',')
data = data.replace(')\n ', ',') data = data.replace(')\n ', ',')
data = data.replace(' ', ' ') data = data.replace(' ', ' ')
output = [] output = []
for line in data.split('\n'): for line in data.split('\n'):
if (line[:7] != 'extern ' and line.find(' extern ') < 0) or line[-1] != ';': if (line[:7] != 'extern ' and line.find(' extern ') < 0) or line[-1] != ';':
continue continue
functionNameEnd = line.find('(') - 1 functionNameEnd = line.find('(') - 1
if functionNameEnd < 0: if functionNameEnd < 0:
continue continue
while line[functionNameEnd] == ' ': while line[functionNameEnd] == ' ':
functionNameEnd = functionNameEnd - 1 functionNameEnd = functionNameEnd - 1
if functionNameEnd < 10: if functionNameEnd < 10:
continue continue
functionNameStart = functionNameEnd functionNameStart = functionNameEnd
while line[functionNameStart] == '_' or line[functionNameStart].isalnum(): while line[functionNameStart] == '_' or line[functionNameStart].isalnum():
functionNameStart = functionNameStart - 1 functionNameStart = functionNameStart - 1
if functionNameStart < 10: if functionNameStart < 10:
continue continue
if line[functionNameStart] != '*' and line[functionNameStart] != ' ': if line[functionNameStart] != '*' and line[functionNameStart] != ' ':
continue continue
functionNameStart = functionNameStart + 1 functionNameStart = functionNameStart + 1
if not line[functionNameStart].isalpha(): if not line[functionNameStart].isalpha():
continue continue
functionName = line[functionNameStart:functionNameEnd+1] functionName = line[functionNameStart:functionNameEnd + 1]
nonnull = None nonnull = None
nonnullStart = line.find('__nonnull') nonnullStart = line.find('__nonnull')
if nonnullStart > 0: if nonnullStart > 0:
nonnullStart = nonnullStart + 9 nonnullStart = nonnullStart + 9
while nonnullStart < len(line) and line[nonnullStart] == ' ': while nonnullStart < len(line) and line[nonnullStart] == ' ':
nonnullStart = nonnullStart + 1 nonnullStart = nonnullStart + 1
if nonnullStart >= len(line) or line[nonnullStart] != '(': if nonnullStart >= len(line) or line[nonnullStart] != '(':
continue continue
while line[nonnullStart] == '(': while line[nonnullStart] == '(':
nonnullStart = nonnullStart + 1 nonnullStart = nonnullStart + 1
nonnullEnd = line.find(')', nonnullStart) nonnullEnd = line.find(')', nonnullStart)
nonnull = line[nonnullStart:nonnullEnd] nonnull = line[nonnullStart:nonnullEnd]
checknonnull(stdcfg, functionName, nonnull) checknonnull(stdcfg, functionName, nonnull)
checknonnull(posixcfg, functionName, nonnull) checknonnull(posixcfg, functionName, nonnull)
if nonnull: if nonnull:
s = functionName + ' ' + nonnull s = functionName + ' ' + nonnull
if s not in output: if s not in output:
output.append(s) output.append(s)
for f in glob.glob('/usr/include/*.h'): for f in glob.glob('/usr/include/*.h'):

View File

@ -29,20 +29,20 @@ out['fp'] = ''
out['tp'] = '' out['tp'] = ''
numberOfFalsePositives = 0 numberOfFalsePositives = 0
numberOfTruePositives = 0 numberOfTruePositives = 0
numberOfFalseNegatives = 0 numberOfFalseNegatives = 0
for result in results.split('\n'): for result in results.split('\n'):
result = result.strip() result = result.strip()
res = re.match('\\[('+project+'.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', result) res = re.match('\\[(' + project + '.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', result)
if res is None: if res is None:
continue continue
filename = res.group(1) filename = res.group(1)
linenr = res.group(2) linenr = res.group(2)
message = res.group(3) message = res.group(3)
css = 'untriaged' css = 'untriaged'
classification = 'Untriaged' classification = 'Untriaged'
if result in truepositives: if result in truepositives:
css = 'tp' css = 'tp'
@ -54,16 +54,16 @@ for result in results.split('\n'):
numberOfFalsePositives += 1 numberOfFalsePositives += 1
href = None href = None
html = ' <tr>' html = ' <tr>'
html += '<td class='+css+'>'+filename+'</td>' html += '<td class=' + css + '>' + filename + '</td>'
html += '<td class='+css+'>'+linenr+'</td>' html += '<td class=' + css + '>' + linenr + '</td>'
html += '<td class='+css+'>'+message+'</td>' html += '<td class=' + css + '>' + message + '</td>'
if project == 'linux-3.11': if project == 'linux-3.11':
href = 'http://github.com/torvalds/linux/blob/v3.11' + filename[filename.find('/'):] + '#L' + linenr href = 'http://github.com/torvalds/linux/blob/v3.11' + filename[filename.find('/'):] + '#L' + linenr
if href: if href:
html += '<td class='+css+'><a href="' + href + '">' + classification + '</a></td>' html += '<td class=' + css + '><a href="' + href + '">' + classification + '</a></td>'
else: else:
html += '<td class='+css+'>' + classification + '</td>' html += '<td class=' + css + '>' + classification + '</td>'
html += '</tr>\n' html += '</tr>\n'
out[css] += html out[css] += html
@ -74,7 +74,7 @@ for line in f.readlines():
if line.find('] -> [') > 0 or line.find('(error)') < 0: if line.find('] -> [') > 0 or line.find('(error)') < 0:
continue continue
res = re.match('\\[('+project+'.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', line) res = re.match('\\[(' + project + '.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', line)
if res is None: if res is None:
continue continue
@ -83,17 +83,17 @@ for line in f.readlines():
numberOfFalseNegatives += 1 numberOfFalseNegatives += 1
filename = res.group(1) filename = res.group(1)
linenr = res.group(2) linenr = res.group(2)
message = res.group(3) message = res.group(3)
classification = 'False Negative' classification = 'False Negative'
css = 'fn' css = 'fn'
html = ' <tr>' html = ' <tr>'
html += '<td class='+css+'>'+filename+'</td>' html += '<td class=' + css + '>' + filename + '</td>'
html += '<td class='+css+'>'+linenr+'</td>' html += '<td class=' + css + '>' + linenr + '</td>'
html += '<td class='+css+'>'+message+'</td>' html += '<td class=' + css + '>' + message + '</td>'
html += '<td class='+css+'>'+classification+'</td>' html += '<td class=' + css + '>' + classification + '</td>'
html += '</tr>\n' html += '</tr>\n'
out[css] += html out[css] += html