do not print source excerpts in bugs.txt

Summary:public
bugs.txt only contains the summary of each report. The terminal output contains
a bit more information, such as source excerpts. If one wants to save the
terminal output into a file, they can always use shell redirection anyway.

closes #294

Reviewed By: martinoluca

Differential Revision: D3023796

fb-gh-sync-id: 9a21d17
shipit-source-id: 9a21d17
master
Jules Villard 9 years ago committed by Facebook Github Bot 5
parent 09f5605a6e
commit 1aa5b1e947

@ -174,12 +174,15 @@ def text_of_report(report):
) )
def _text_of_report_list(reports): def _text_of_report_list(reports, formatter=source.TERMINAL_FORMATTER):
text_errors_list = [] text_errors_list = []
error_types_count = {} error_types_count = {}
for report in reports: for report in reports:
filename = report[JSON_INDEX_FILENAME] filename = report[JSON_INDEX_FILENAME]
line = report[JSON_INDEX_LINE] line = report[JSON_INDEX_LINE]
source_context = ''
if formatter is not None:
source_context = source.build_source_context( source_context = source.build_source_context(
filename, filename,
source.TERMINAL_FORMATTER, source.TERMINAL_FORMATTER,
@ -188,8 +191,9 @@ def _text_of_report_list(reports):
indenter = source.Indenter() \ indenter = source.Indenter() \
.indent_push() \ .indent_push() \
.add(source_context) .add(source_context)
source_context = unicode(indenter) source_context = '\n' + unicode(indenter)
text = '%s\n%s' % (text_of_report(report), source_context)
text = '%s%s' % (text_of_report(report), source_context)
text_errors_list.append(text) text_errors_list.append(text)
t = report[JSON_INDEX_TYPE] t = report[JSON_INDEX_TYPE]
@ -205,7 +209,7 @@ def _text_of_report_list(reports):
n_issues = len(text_errors_list) n_issues = len(text_errors_list)
if n_issues == 0: if n_issues == 0:
return 'No issues found' return 'No issues found'
else:
max_type_length = max(map(len, error_types_count.keys())) + 2 max_type_length = max(map(len, error_types_count.keys())) + 2
sorted_error_types = error_types_count.items() sorted_error_types = error_types_count.items()
sorted_error_types.sort(key=operator.itemgetter(1), reverse=True) sorted_error_types.sort(key=operator.itemgetter(1), reverse=True)
@ -216,7 +220,7 @@ def _text_of_report_list(reports):
text_errors = '\n\n'.join(text_errors_list) text_errors = '\n\n'.join(text_errors_list)
msg = '\nFound %s\n\n%s\n\nSummary of the reports:\n\n%s' % ( msg = 'Found %s\n\n%s\n\nSummary of the reports:\n\n%s' % (
utils.get_plural('issue', n_issues), utils.get_plural('issue', n_issues),
text_errors, text_errors,
'\n'.join(types_text_list), '\n'.join(types_text_list),
@ -234,11 +238,10 @@ def _is_user_visible(report):
def print_and_save_errors(json_report, bugs_out): def print_and_save_errors(json_report, bugs_out):
errors = utils.load_json_from_path(json_report) errors = utils.load_json_from_path(json_report)
errors = filter(_is_user_visible, errors) errors = filter(_is_user_visible, errors)
text = _text_of_report_list(errors) utils.stdout('\n' + _text_of_report_list(errors))
utils.stdout(text)
with codecs.open(bugs_out, 'w', with codecs.open(bugs_out, 'w',
encoding=config.LOCALE, errors='replace') as file_out: encoding=config.LOCALE, errors='replace') as file_out:
file_out.write(text) file_out.write(_text_of_report_list(errors, formatter=None))
def merge_reports_from_paths(report_paths): def merge_reports_from_paths(report_paths):

Loading…
Cancel
Save