From 2b8e8dec7f154854ce630bf4e518c7b439cd8659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FDeniz=3D20T=3DC3=3DBCrkoglu=3F=3D?= Date: Fri, 17 Jul 2015 12:00:13 -0700 Subject: [PATCH] Indent json files Summary: The json files that were written by json.dump were valid, machine readable but they had no indentation/return lines making them a long single line and hard to read. Dump the json with an indent of 2. Closes https://github.com/facebook/infer/pull/149 Github Author: =?UTF-8?q?Deniz=20T=C3=BCrkoglu?= --- infer/bin/BuckAnalyze | 2 +- infer/bin/inferlib.py | 2 +- infer/bin/utils.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infer/bin/BuckAnalyze b/infer/bin/BuckAnalyze index f79cf09e8..7da11f182 100755 --- a/infer/bin/BuckAnalyze +++ b/infer/bin/BuckAnalyze @@ -440,7 +440,7 @@ def collect_results(args, start_time): stats_filename = os.path.join(args.infer_out, utils.STATS_FILENAME) with open(stats_filename, 'w') as stats_out: - json.dump(stats, stats_out) + json.dump(stats, stats_out, indent=2) basic_stats = get_basic_stats(stats) diff --git a/infer/bin/inferlib.py b/infer/bin/inferlib.py index e52e0d633..8ccfaa3e4 100644 --- a/infer/bin/inferlib.py +++ b/infer/bin/inferlib.py @@ -629,7 +629,7 @@ class Infer: self.stats['normal']['infer_version'] = utils.infer_version() with open(stats_path, 'w') as stats_file: - json.dump(self.stats, stats_file) + json.dump(self.stats, stats_file, indent=2) def close(self): if self.args.analyzer != COMPILE: diff --git a/infer/bin/utils.py b/infer/bin/utils.py index 3a5ba97f9..5b332a890 100644 --- a/infer/bin/utils.py +++ b/infer/bin/utils.py @@ -348,8 +348,8 @@ def create_json_report(out_dir): rows = [row for row in reader] with open(json_report_filename, 'w') as file_out: headers = rows[0] - issues = rows[1:] - json.dump([dict(zip(headers, row)) for row in issues], file_out) + issues = [dict(zip(headers, row)) for row in rows[1:]] + json.dump(issues, file_out, indent=2) class AbsolutePathAction(argparse.Action):