[UI] only colorize the top 10 reports, do not compile report lists within Buck

Summary: This was a big bottleneck.

Reviewed By: sblackshear

Differential Revision: D4707566

fbshipit-source-id: 548b891
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 1a8e99963c
commit fe51f08ae9

@ -88,9 +88,17 @@ def text_of_report(report):
def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None,
formatter=colorize.TERMINAL_FORMATTER):
n_issues = len(reports)
if n_issues == 0:
if formatter == colorize.TERMINAL_FORMATTER:
out = colorize.color(' No issues found ',
colorize.SUCCESS, formatter)
return out + '\n'
else:
return 'No issues found'
text_errors_list = []
error_types_count = {}
for report in reports:
for report in reports[:limit]:
filename = report[JSON_INDEX_FILENAME]
line = report[JSON_INDEX_LINE]
@ -115,6 +123,8 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None,
text = '%s%s' % (msg, source_context)
text_errors_list.append(text)
error_types_count = {}
for report in reports:
t = report[JSON_INDEX_TYPE]
# assert failures are not very informative without knowing
# which assertion failed
@ -125,15 +135,6 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None,
else:
error_types_count[t] += 1
n_issues = len(text_errors_list)
if n_issues == 0:
if formatter == colorize.TERMINAL_FORMATTER:
out = colorize.color(' No issues found ',
colorize.SUCCESS, formatter)
return out + '\n'
else:
return 'No issues found'
max_type_length = max(map(len, error_types_count.keys())) + 2
sorted_error_types = error_types_count.items()
sorted_error_types.sort(key=operator.itemgetter(1), reverse=True)
@ -142,7 +143,7 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None,
count,
), sorted_error_types)
text_errors = '\n\n'.join(text_errors_list[:limit])
text_errors = '\n\n'.join(text_errors_list)
if limit >= 0 and n_issues > limit:
text_errors += colorize.color(
('\n\n...too many issues to display (limit=%d exceeded), please ' +

@ -303,9 +303,13 @@ let report () =
let report_csv = Some (Config.results_dir ^/ "report.csv") in
let report_json = Some (Config.results_dir ^/ "report.json") in
InferPrint.main ~report_csv ~report_json ;
match Config.report_hook with
| None -> ()
| Some prog ->
(* Post-process the report according to the user config. By default, calls report.py to create a
human-readable report. *)
match Config.buck, Config.report_hook with
| true, _ (* do not bother calling the report hook when called from within Buck *)
| false, None ->
()
| false, Some prog ->
let if_some key opt args = match opt with None -> args | Some arg -> key :: arg :: args in
let if_true key opt args = if not opt then args else key :: args in
let args =

Loading…
Cancel
Save