@@ -275,15 +275,17 @@ class AnnotateCodeFormatter(HtmlFormatter):
275275 if error ['line' ] == line_no :
276276 try :
277277 if error ['inconclusive' ] == 'true' :
278- if error .get ('verbose' ) and (error ['verbose' ] != error ['msg' ]): # only print verbose msg if it really differs from actual message
278+ # only print verbose msg if it really differs
279+ # from actual message
280+ if error .get ('verbose' ) and (error ['verbose' ] != error ['msg' ]):
279281 index = t .rfind ('\n ' )
280- t = t [:index ] + HTML_EXPANDABLE_INCONCLUSIVE % (error ['msg' ], html_escape (error ['verbose' ].replace ("\\ 012" , '\n ' ))) + t [index + 1 :]
282+ t = t [:index ] + HTML_EXPANDABLE_INCONCLUSIVE % (error ['msg' ], html_escape (error ['verbose' ].replace ("\\ 012" , '\n ' ))) + t [index + 1 :]
281283 else :
282284 t = t .replace ('\n ' , HTML_INCONCLUSIVE % error ['msg' ])
283285 except KeyError :
284286 if error .get ('verbose' ) and (error ['verbose' ] != error ['msg' ]):
285287 index = t .rfind ('\n ' )
286- t = t [:index ] + HTML_EXPANDABLE_ERROR % (error ['msg' ], html_escape (error ['verbose' ].replace ("\\ 012" , '\n ' ))) + t [index + 1 :]
288+ t = t [:index ] + HTML_EXPANDABLE_ERROR % (error ['msg' ], html_escape (error ['verbose' ].replace ("\\ 012" , '\n ' ))) + t [index + 1 :]
287289 else :
288290 t = t .replace ('\n ' , HTML_ERROR % error ['msg' ])
289291
@@ -521,7 +523,7 @@ if __name__ == '__main__':
521523 except IndexError :
522524 cnt_min = 0
523525
524- for occurrences in reversed (range (cnt_min , cnt_max + 1 )):
526+ for occurrences in reversed (range (cnt_min , cnt_max + 1 )):
525527 for _id in [k for k , v in sorted (Counter (stats ).items ()) if v == occurrences ]:
526528 stat_html .append (" " + str (dict (Counter (stats ).most_common ())[_id ]) + " " + str (_id ) + "<br/>\n " )
527529
@@ -584,14 +586,13 @@ if __name__ == '__main__':
584586 'w' ) as css_file :
585587 css_file .write (STYLE_FILE )
586588
587-
588589 print ("Creating stats.html (statistics)\n " )
589- stats_countlist = {}
590+ stats_countlist = {}
590591
591592 for filename , data in sorted (files .items ()):
592593 if (filename == '' ):
593594 continue
594- stats_tmplist = []
595+ stats_tmplist = []
595596 for error in sorted (data ['errors' ], key = lambda k : k ['line' ]):
596597 stats_tmplist .append (error ['severity' ])
597598
@@ -607,37 +608,39 @@ if __name__ == '__main__':
607608
608609 for sev in SEVERITIES :
609610 _sum = 0
610- stats_templist = {}
611+ stats_templist = {}
611612
612- try : # if the we have an style warning but we are checking for portability, we have to skip it to prevent KeyError
613+ # if the we have an style warning but we are checking for
614+ # portability, we have to skip it to prevent KeyError
615+ try :
613616 for filename in stats_countlist :
614- try : # also bail out if we have a file with no sev-results
617+ try : # also bail out if we have a file with no sev-results
615618 _sum += stats_countlist [filename ][sev ]
616- stats_templist [filename ] = (int )(stats_countlist [filename ][sev ]) # file : amount,
619+ stats_templist [filename ] = (int )(stats_countlist [filename ][sev ]) # file : amount,
617620 except KeyError :
618621 continue
619- if (_sum == 0 ): # don't print "0 style" etc, if no style warnings were found
622+ # don't print "0 style" etc, if no style warnings were found
623+ if (_sum == 0 ):
620624 break
621625 except KeyError :
622626 continue
623627 stats_file .write ("<p>Top 10 files for " + sev + " severity, total findings: " + str (_sum ) + "</br>\n " )
624628
625-
626629 # sort, so that the file with the most severities per type is first
627- stats_list_sorted = sorted (stats_templist .items (), key = operator .itemgetter (1 ,0 ), reverse = True )
630+ stats_list_sorted = sorted (stats_templist .items (), key = operator .itemgetter (1 , 0 ), reverse = True )
628631 it = 0
629632 LENGTH = 0
630633
631- for i in stats_list_sorted : # printing loop
632- # for aesthetics: if it's the first iteration of the loop, get the max length of the number string
634+ for i in stats_list_sorted : # printing loop
635+ # for aesthetics: if it's the first iteration of the loop, get
636+ # the max length of the number string
633637 if (it == 0 ):
634- LENGTH = len (str (i [1 ])) # <- length of longest number, now get the difference and try to make other numbers align to it
638+ LENGTH = len (str (i [1 ])) # <- length of longest number, now get the difference and try to make other numbers align to it
635639
636- stats_file .write (" " * 3 + str (i [1 ]) + " " * (1 + LENGTH - len (str (i [1 ]))) + "<a href=\" " + files [i [0 ]]['htmlfile' ] + "\" > " + i [0 ] + "</a></br>\n " )
640+ stats_file .write (" " * 3 + str (i [1 ]) + " " * (1 + LENGTH - len (str (i [1 ]))) + "<a href=\" " + files [i [0 ]]['htmlfile' ] + "\" > " + i [0 ] + "</a></br>\n " )
637641 it += 1
638- if (it == 10 ): # print only the top 10
642+ if (it == 10 ): # print only the top 10
639643 break
640644 stats_file .write ("</p>\n " )
641645
642646 print ("\n Open '" + options .report_dir + "/index.html' to see the results." )
643-
0 commit comments