read errors from json instead of csv

Summary: public
This also fixes an issue with utf-8 in source code, as the csv report filters
out non-ascii characters.

Reviewed By: akotulski

Differential Revision: D2641727

fb-gh-sync-id: 3ca6dc6
master
Jules Villard 9 years ago committed by facebook-github-bot-1
parent ae81d8d215
commit f72a1a4210

@ -448,7 +448,7 @@ def collect_results(args, start_time):
report.flush()
print('\n')
analyze.print_errors(csv_report, bugs_out)
analyze.print_errors(json_report, bugs_out)
stats['int']['total_time'] = int(round(utils.elapsed_time(start_time)))

@ -394,25 +394,23 @@ def print_and_write(file_out, message):
file_out.write(message + '\n')
def print_errors(csv_report, bugs_out):
with codecs.open(csv_report, 'r', encoding=utils.LOCALE) as file_in:
reader = utils.locale_csv_reader(file_in)
reader.next() # first line is header, skip it
def print_errors(json_report, bugs_out):
with codecs.open(json_report, 'r', encoding=utils.LOCALE) as file_in:
errors = json.load(file_in)
errors = filter(
lambda row: row[utils.CSV_INDEX_KIND] in [ERROR, WARNING],
reader
)
lambda row: row[utils.JSON_INDEX_KIND] in [ERROR, WARNING],
errors)
with codecs.open(bugs_out, 'w', encoding=utils.LOCALE) as file_out:
text_errors_list = []
for row in errors:
filename = row[utils.CSV_INDEX_FILENAME]
filename = row[utils.JSON_INDEX_FILENAME]
if os.path.isfile(filename):
kind = row[utils.CSV_INDEX_KIND]
line = row[utils.CSV_INDEX_LINE]
error_type = row[utils.CSV_INDEX_TYPE]
msg = row[utils.CSV_INDEX_QUALIFIER]
kind = row[utils.JSON_INDEX_KIND]
line = row[utils.JSON_INDEX_LINE]
error_type = row[utils.JSON_INDEX_TYPE]
msg = row[utils.JSON_INDEX_QUALIFIER]
indenter = utils.Indenter()
indenter.indent_push()
indenter.add(
@ -761,11 +759,11 @@ class Infer:
self.read_proc_stats()
self.print_analysis_stats()
if report_status == os.EX_OK and not self.args.buck:
csv_report = os.path.join(self.args.infer_out,
utils.CSV_REPORT_FILENAME)
json_report = os.path.join(self.args.infer_out,
utils.JSON_REPORT_FILENAME)
bugs_out = os.path.join(self.args.infer_out,
utils.BUGS_FILENAME)
print_errors(csv_report, bugs_out)
print_errors(json_report, bugs_out)
def print_analysis_stats(self):
procs_total = self.stats['int']['procedures']

Loading…
Cancel
Save