diff --git a/src/staticanalysis/bot/static_analysis_bot/report/base.py b/src/staticanalysis/bot/static_analysis_bot/report/base.py index 8aa8677096..8c17ce5883 100644 --- a/src/staticanalysis/bot/static_analysis_bot/report/base.py +++ b/src/staticanalysis/bot/static_analysis_bot/report/base.py @@ -14,7 +14,7 @@ COMMENT_PARTS = { ClangTidyIssue: { 'defect': ' - {nb} found by clang-tidy', - 'analyzer': ' - `./mach static-analysis check path/to/file.cpp` (C/C++)', + 'analyzer': ' - `./mach static-analysis check {files}` (C/C++)', }, InferIssue: { 'defect': ' - {nb} found by infer', @@ -25,7 +25,7 @@ }, ClangFormatIssue: { 'defect': ' - {nb} found by clang-format', - 'analyzer': ' - `./mach clang-format -s -p path/to/file.cpp` (C/C++)', + 'analyzer': ' - `./mach clang-format -s -p {files}` (C/C++)', }, MozLintIssue: { 'defect': ' - {nb} found by mozlint', @@ -103,7 +103,8 @@ def stats(items): _items = list(items) return { 'total': len(_items), - 'publishable': sum([i.is_publishable() for i in _items]) + 'publishable': sum([i.is_publishable() for i in _items]), + 'publishable_paths': list({i.path for i in _items if i.is_publishable()}) } from collections import OrderedDict @@ -134,7 +135,7 @@ def pluralize(word, nb): nb=pluralize('defect', cls_stats['publishable']) )) if 'analyzer' in part: - analyzers.append(part['analyzer']) + analyzers.append(part['analyzer'].format(files=' '.join(cls_stats['publishable_paths']))) # Build top comment nb = len(issues) diff --git a/src/staticanalysis/bot/tests/conftest.py b/src/staticanalysis/bot/tests/conftest.py index fc1eddd572..c856548450 100644 --- a/src/staticanalysis/bot/tests/conftest.py +++ b/src/staticanalysis/bot/tests/conftest.py @@ -115,6 +115,7 @@ def mock_issues(): class MockIssue(object): def __init__(self, nb): self.nb = nb + self.path = '/path/to/file' def as_markdown(self): return 'This is the mock issue n°{}'.format(self.nb) diff --git a/src/staticanalysis/bot/tests/test_reporter_mail.py b/src/staticanalysis/bot/tests/test_reporter_mail.py index 49cec55955..098c742f26 100644 --- a/src/staticanalysis/bot/tests/test_reporter_mail.py +++ b/src/staticanalysis/bot/tests/test_reporter_mail.py @@ -119,5 +119,6 @@ def _check_email(request): mock_cls: { 'total': 5, 'publishable': 3, + 'publishable_paths': ['/path/to/file'] } } diff --git a/src/staticanalysis/bot/tests/test_reporter_phabricator.py b/src/staticanalysis/bot/tests/test_reporter_phabricator.py index fb1e1c1f05..c7b629fa9c 100644 --- a/src/staticanalysis/bot/tests/test_reporter_phabricator.py +++ b/src/staticanalysis/bot/tests/test_reporter_phabricator.py @@ -16,7 +16,7 @@ - 1 defect found by clang-tidy You can run this analysis locally with: - - `./mach static-analysis check path/to/file.cpp` (C/C++) + - `./mach static-analysis check another_test.cpp` (C/C++) If you see a problem in this automated review, [please report it here](https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox+Build+System&component=Source+Code+Analysis&short_desc=[Automated+review]+UPDATE&comment=**Phabricator+URL:**+https://phabricator.services.mozilla.com/...&format=__default__). ''' # noqa @@ -26,7 +26,7 @@ - 1 defect found by clang-format You can run this analysis locally with: - - `./mach clang-format -s -p path/to/file.cpp` (C/C++) + - `./mach clang-format -s -p dom/test.cpp` (C/C++) For your convenience, [here is a patch]({results}/clang-format-PHID-DIFF-abcdef.diff) that fixes all the clang-format defects (use it in your repository with `hg import` or `git apply`). @@ -85,11 +85,11 @@ def _check_comment(request): revision = PhabricatorRevision(api, 'PHID-DIFF-abcdef') revision.lines = { # Add dummy lines diff - 'test.cpp': [41, 42, 43], + 'another_test.cpp': [41, 42, 43], } reporter = PhabricatorReporter({'analyzers': ['clang-tidy'], 'modes': ('comment')}, api=api) - issue = ClangTidyIssue(revision, 'test.cpp', '42', '51', 'modernize-use-nullptr', 'dummy message', 'error') + issue = ClangTidyIssue(revision, 'another_test.cpp', '42', '51', 'modernize-use-nullptr', 'dummy message', 'error') assert issue.is_publishable() issues, patches = reporter.publish([issue, ], revision)