diff --git a/tools/warn.py b/tools/warn.py index 8ea45df40..bb3b08d98 100755 --- a/tools/warn.py +++ b/tools/warn.py @@ -30,9 +30,24 @@ def colorforseverity(sev): if sev == severity.HARMLESS: return 'limegreen' if sev == severity.UNKNOWN: - return 'blue' + return 'lightblue' return 'grey' +def headerforseverity(sev): + if sev == severity.FIXMENOW: + return 'Critical warnings, fix me now' + if sev == severity.HIGH: + return 'High severity warnings' + if sev == severity.MEDIUM: + return 'Medium severity warnings' + if sev == severity.LOW: + return 'Low severity warnings' + if sev == severity.HARMLESS: + return 'Harmless warnings' + if sev == severity.UNKNOWN: + return 'Unknown warnings' + return 'Unhandled warnings' + warnpatterns = [ { 'category':'make', 'severity':severity.MEDIUM, 'members':[], 'option':'', 'description':'make: overriding commands/ignoring old commands', @@ -623,16 +638,21 @@ def tablerow(text): output(text,) output('') -def begintable(text, backgroundcolor): +def begintable(text, backgroundcolor, extraanchor): global anchor output('') - output('') anchor += 1 @@ -650,13 +670,43 @@ def dumpstats(): unknown += len(i['members']) elif i['severity'] != severity.SKIP: known += len(i['members']) - output('Number of classified warnings: ' + str(known) + '
' ) - output('Number of unclassified warnings: ' + str(unknown) + '
') + output('\nNumber of classified warnings: ' + str(known) + '
' ) + output('\nNumber of unclassified warnings: ' + str(unknown) + '
') total = unknown + known - output('Total number of warnings: ' + str(total) + '') + output('\nTotal number of warnings: ' + str(total) + '') if total < 1000: output('(low count may indicate incremental build)') - output('

') + output('\n

\n') + +# dump count of warnings of a given severity in TOC +def dumpcount(sev): + first = True + for i in warnpatterns: + if i['severity'] == sev and len(i['members']) > 0: + if first: + output(headerforseverity(sev) + ':\n

' + + '
') + backgroundcolor + '">') + if extraanchor: + output('') + output('') output(htmlbig(text[0]) + '
') for i in text[1:]: output(i + '
') output('
previous
next') + output('
' + + 'top
' + + 'previous
' + + 'next') output('
') + output('' + + '\n') + first = False + if not first: + output('
' + descriptionfor(i) + + ' (' + str(len(i['members'])) + ')
\n') + +# dump table of content, list of all warning patterns +def dumptoc(): + n = 1 + output('
\n') + for i in warnpatterns: + i['anchor'] = 'Warning' + str(n) + n += 1 + dumpcount(severity.FIXMENOW) + dumpcount(severity.HIGH) + dumpcount(severity.MEDIUM) + dumpcount(severity.LOW) + dumpcount(severity.HARMLESS) + dumpcount(severity.UNKNOWN) + output('
\n

\n') def allpatterns(cat): pats = '' @@ -678,7 +728,7 @@ def dumpfixed(): if len(i['members']) == 0 and i['severity'] != severity.SKIP: if tablestarted == False: tablestarted = True - begintable(['Fixed warnings', 'No more occurences. Please consider turning these in to errors if possible, before they are reintroduced in to the build'], 'blue') + begintable(['Fixed warnings', 'No more occurences. Please consider turning these in to errors if possible, before they are reintroduced in to the build'], 'blue', '') tablerow(i['description'] + ' (' + allpatterns(i) + ') ' + i['option']) if tablestarted: endtable() @@ -690,7 +740,7 @@ def dumpcategory(cat): header = [descriptionfor(cat),str(len(cat['members'])) + ' occurences:'] if cat['option'] != '': header[1:1] = [' (related option: ' + cat['option'] +')'] - begintable(header, colorforseverity(cat['severity'])) + begintable(header, colorforseverity(cat['severity']), cat['anchor']) for i in cat['members']: tablerow(i) endtable() @@ -761,6 +811,7 @@ for line in infile: # dump the html output to stdout dumphtmlprologue('Warnings for ' + platformversion + ' - ' + targetproduct + ' - ' + targetvariant) dumpstats() +dumptoc() dumpseverity(severity.FIXMENOW) dumpseverity(severity.HIGH) dumpseverity(severity.MEDIUM)