diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index d834fc830..031854afc 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -294,7 +294,7 @@ def collect_results(args, start_time, targets): with open(os.path.join(args.infer_out, ANALYSIS_SUMMARY_OUTPUT), 'w') as f: f.write(buck_stats) - all_json_rows = [] + all_json_rows = set() stats = init_stats(args, start_time) accumulation_whitelist = list(map(re.compile, [ @@ -328,7 +328,9 @@ def collect_results(args, start_time, targets): old_value = stats[type_k].get(key, 0) stats[type_k][key] = old_value + value - all_json_rows += load_json_report(jar) + json_rows = load_json_report(jar) + for row in json_rows: + all_json_rows.add(json.dumps(row)) # Override normals stats['normal'].update(target_stats.get('normal', {})) @@ -338,7 +340,6 @@ def collect_results(args, start_time, targets): logging.warn('Bad zip file %s', path) json_report = os.path.join(args.infer_out, config.JSON_REPORT_FILENAME) - utils.dump_json_to_path(all_json_rows, json_report) # Convert all float values to integer values for key, value in stats.get('float', {}).items(): @@ -347,7 +348,15 @@ def collect_results(args, start_time, targets): # Delete the float entries before exporting the results del(stats['float']) + with open(json_report, 'w') as report: + json_string = '[' + json_string += ','.join(all_json_rows) + json_string += ']' + report.write(json_string) + report.flush() + print('\n') + json_report = os.path.join(args.infer_out, config.JSON_REPORT_FILENAME) bugs_out = os.path.join(args.infer_out, config.BUGS_FILENAME) issues.print_and_save_errors(args.infer_out, args.project_root, json_report, bugs_out, args.pmd_xml) diff --git a/infer/lib/python/inferlib/utils.py b/infer/lib/python/inferlib/utils.py index 183fa1a26..fc09714c5 100644 --- a/infer/lib/python/inferlib/utils.py +++ b/infer/lib/python/inferlib/utils.py @@ -97,7 +97,7 @@ def dump_json_to_path( skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=2, # customized - separators=(',', ': '), # default is (', ', ': ') with trailing space + separators=None, encoding=config.CODESET, # customized default=None, sort_keys=False, **kw): with codecs.open(path, 'w',