From febe21037a8c6920026704b9575f628781f9e305 Mon Sep 17 00:00:00 2001 From: Andi-Bogdan Postelnicu Date: Fri, 17 May 2019 13:58:48 +0300 Subject: [PATCH] staticanalysis/bot: Append diff-id to the linting messages. --- src/staticanalysis/bot/static_analysis_bot/report/base.py | 5 +++-- .../bot/static_analysis_bot/report/phabricator.py | 1 + src/staticanalysis/bot/tests/test_reporter_phabricator.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/staticanalysis/bot/static_analysis_bot/report/base.py b/src/staticanalysis/bot/static_analysis_bot/report/base.py index 2caf1af887..593c63cd5c 100644 --- a/src/staticanalysis/bot/static_analysis_bot/report/base.py +++ b/src/staticanalysis/bot/static_analysis_bot/report/base.py @@ -33,7 +33,7 @@ }, } COMMENT_FAILURE = ''' -Code analysis found {defects_total} in this patch{extras_comments}: +Code analysis found {defects_total} in this patch diff n°{diff_id}{extras_comments}: {defects} ''' COMMENT_RUN_ANALYZERS = ''' @@ -113,7 +113,7 @@ def stats(items): for cls, items in groups ]) - def build_comment(self, issues, bug_report_url, patches=[]): + def build_comment(self, revision, issues, bug_report_url, patches=[]): ''' Build a Markdown comment about published issues ''' @@ -144,6 +144,7 @@ def pluralize(word, nb): comment = COMMENT_FAILURE.format( extras_comments=extras, defects_total=pluralize('defect', nb), + diff_id=revision.diff_id, defects='\n'.join(defects), ) diff --git a/src/staticanalysis/bot/static_analysis_bot/report/phabricator.py b/src/staticanalysis/bot/static_analysis_bot/report/phabricator.py index 5c5d6d259f..46f7411c9e 100644 --- a/src/staticanalysis/bot/static_analysis_bot/report/phabricator.py +++ b/src/staticanalysis/bot/static_analysis_bot/report/phabricator.py @@ -105,6 +105,7 @@ def publish_comment(self, revision, issues, patches): self.api.comment( revision.id, self.build_comment( + revision=revision, issues=non_coverage_issues, patches=patches, bug_report_url=BUG_REPORT_URL, diff --git a/src/staticanalysis/bot/tests/test_reporter_phabricator.py b/src/staticanalysis/bot/tests/test_reporter_phabricator.py index 5d7cb9e262..18042bcbd6 100644 --- a/src/staticanalysis/bot/tests/test_reporter_phabricator.py +++ b/src/staticanalysis/bot/tests/test_reporter_phabricator.py @@ -11,7 +11,7 @@ import responses VALID_CLANG_TIDY_MESSAGE = ''' -Code analysis found 1 defect in this patch: +Code analysis found 1 defect in this patch diff n°42: - 1 defect found by clang-tidy You can run this analysis locally with: @@ -21,7 +21,7 @@ ''' # noqa VALID_CLANG_FORMAT_MESSAGE = ''' -Code analysis found 1 defect in this patch: +Code analysis found 1 defect in this patch diff n°42: - 1 defect found by clang-format You can run this analysis locally with: