\n')
def allpatterns(cat):
@@ -2017,19 +2026,35 @@ def warningwithurl(line):
else:
return '' + filepath + ':' + linenumber + ':' + warning
-# dump a category, provided it is not marked as 'SKIP' and has more than 0 occurrences
-def dumpcategory(cat):
- if cat['severity'] != severity.SKIP and len(cat['members']) != 0:
- header = [descriptionfor(cat),str(len(cat['members'])) + ' occurences:']
- if cat['option'] != '':
- header[1:1] = [' (related option: ' + cat['option'] +')']
+def dumpgroup(sev, anchor, description, warnings):
+ mark = anchor + '_mark'
+ output('\n
\n')
+ output('
' +
+ '
' + description + '
\n')
+ output('
\n')
+ output('
')
+ output('
\n')
+ for i in warnings:
+ tablerow(warningwithurl(i))
+ output('
\n')
- output('
')
- output('
\n')
- for i in cat['members']:
- tablerow(warningwithurl(i))
- output('
\n')
+# dump warnings in a category
+def dumpcategory(sev, cat):
+ description = descriptionfor(cat) + ' (' + str(len(cat['members'])) + ')'
+ dumpgroup(sev, cat['anchor'], description, cat['members'])
+# similar to dumpcategory but output one table per project.
+def dumpcategorybyproject(sev, cat):
+ warning = descriptionfor(cat)
+ projects = cat['projectwarning'].keys()
+ projects.sort()
+ for p in projects:
+ anchor = cat['projectanchor'][p]
+ projectwarnings = cat['projectwarning'][p]
+ description = '{}, in {} ({})'.format(warning, p, len(projectwarnings))
+ dumpgroup(sev, anchor, description, projectwarnings)
def findproject(line):
for p in projectpatterns:
@@ -2038,15 +2063,26 @@ def findproject(line):
return '???'
def classifywarning(line):
+ global anchor
for i in warnpatterns:
for cpat in i['compiledpatterns']:
if cpat.match(line):
i['members'].append(line)
pname = findproject(line)
+ # Count warnings by project.
if pname in i['projects']:
- i['projects'][pname] += 1
+ i['projects'][pname] += 1
else:
- i['projects'][pname] = 1
+ i['projects'][pname] = 1
+ # Collect warnings by project.
+ if args.byproject:
+ if pname in i['projectwarning']:
+ i['projectwarning'][pname].append(line)
+ else:
+ i['projectwarning'][pname] = [line]
+ if pname not in i['projectanchor']:
+ anchor += 1
+ i['projectanchor'][pname] = str(anchor)
return
else:
# If we end up here, there was a problem parsing the log