From 55b716f8ce506eddd3684c01cd584efb66fa6960 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Thu, 12 Dec 2019 16:20:50 +0100 Subject: [PATCH] Reverse sort by count and item name in the summary When two files have the same number of warnings, they will appear in the same order in the summary, making the diff between different build logs smaller. --- scripts/count-warnings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/count-warnings.py b/scripts/count-warnings.py index f923031f..df3b1887 100755 --- a/scripts/count-warnings.py +++ b/scripts/count-warnings.py @@ -74,11 +74,11 @@ def find_longest_name_length(names): def print_summary(issues): - summary = list(issues.items()) size = find_longest_name_length(issues.keys()) + 1 - for warning, count in sorted(summary, key=lambda x: -x[1]): + items = list(issues.items()) + for name, count in sorted(items, key=lambda x: (x[1], x[0]), reverse=True): print(' {text:{field_size}s}: {count}'.format( - text=warning, count=count, field_size=size)) + text=name, count=count, field_size=size)) print()