From b0a54956116a22d0818a3b7342ab1447839386a9 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 6 Dec 2016 04:18:18 -0800 Subject: [PATCH] [UI] add source context to reports in bugs.txt Summary: Now that the terminal output is truncated to max 10 issues, it's useful to have some place where all bugs with source excerpts can be found. Since bugs.txt is already unstructured (to the extend that it's just text), hopefully no one was relying on it having a particular format so it's safe to change it to add source excerpts. Anyone wanting the old behaviour should consider parsing report.json instead, which is intended to be more stable. Closes https://github.com/facebook/infer/issues/520 Reviewed By: akotulski Differential Revision: D4284175 fbshipit-source-id: 764f291 --- infer/lib/python/inferlib/issues.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/infer/lib/python/inferlib/issues.py b/infer/lib/python/inferlib/issues.py index 4168ca93d..08aec2c06 100644 --- a/infer/lib/python/inferlib/issues.py +++ b/infer/lib/python/inferlib/issues.py @@ -98,16 +98,15 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None, line = report[JSON_INDEX_LINE] source_context = '' - if formatter == colorize.TERMINAL_FORMATTER: - source_context = source.build_source_context( - os.path.join(project_root, filename), - formatter, - line, - ) - indenter = source.Indenter() \ - .indent_push() \ - .add(source_context) - source_context = '\n' + unicode(indenter) + source_context = source.build_source_context( + os.path.join(project_root, filename), + formatter, + line, + ) + indenter = source.Indenter() \ + .indent_push() \ + .add(source_context) + source_context = '\n' + unicode(indenter) msg = text_of_report(report) if report[JSON_INDEX_KIND] == ISSUE_KIND_ERROR: