[cmd] Print summary at the end of parse command
Print summary at the end of parse command instead of at the end
of each input directory parse.
@@ -600,6 +600,9 @@ def main(args):
return skip
file_change = set()
+ severity_stats = defaultdict(int)
+ file_stats = defaultdict(int)
+ report_count = 0
for input_path in args.input:
@@ -664,9 +667,16 @@ def main(args):
file_change = file_change.union(f_change)
report_stats = rh.write(file_report_map)
- severity_stats = report_stats.get('severity')
- file_stats = report_stats.get('files')
- reports_stats = report_stats.get('reports')
+ sev_stats = report_stats.get('severity')
+ for severity in sev_stats:
+ severity_stats[severity] += sev_stats[severity]
+
+ f_stats = report_stats.get('files')
+ for file_path in f_stats:
+ file_stats[file_path] += f_stats[file_path]
+
+ rep_stats = report_stats.get('reports')
+ report_count += rep_stats.get("report_count", 0)
print("\n----==== Summary ====----")
if file_stats:
@@ -682,7 +692,6 @@ def main(args):
table = twodim_to_str('table', keys, vals, 1, True)
print(table)
- report_count = reports_stats.get("report_count", 0)
print("----=================----")
print("Total number of reports: {}".format(report_count))
print("----=================----")
