Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

staticanalysis/bot: Do not publish clang-format issues on third party… #1736

Merged
merged 1 commit into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/staticanalysis/bot/static_analysis_bot/clang/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def validates(self):
'''
Should match one of the allowed paths rules
'''
return settings.is_allowed_path(self.path)
return settings.is_allowed_path(self.path) \
and not self.is_third_party()

def as_text(self):
'''
Expand Down
2 changes: 1 addition & 1 deletion src/staticanalysis/bot/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def mock_config():

from static_analysis_bot.config import settings
tempdir = tempfile.mkdtemp()
settings.setup('test', tempdir, 'IN_PATCH', ['dom/*', 'tests/*.py'])
settings.setup('test', tempdir, 'IN_PATCH', ['dom/*', 'tests/*.py', 'test/*.c'])

return settings

Expand Down
18 changes: 18 additions & 0 deletions src/staticanalysis/bot/tests/test_clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,21 @@ def test_repeats(mock_clang_repeats, mock_revision, mock_config):
assert len(issues) == 3
count = Counter(i.check for i in issues)
assert count['modernize-loop-convert'] == 1


def test_clang_format_3rd_party(mock_repository, mock_revision):
'''
Test a clang format issue in 3rd party is not publishable
'''
from static_analysis_bot.clang.format import ClangFormatIssue

mock_revision.lines = {
'test/not_3rd.c': [10, ],
'test/dummy/third_party.c': [10, ],
}
issue = ClangFormatIssue('test/not_3rd.c', 10, 1, mock_revision)
assert issue.is_publishable()

# test/dummy is a third party directory
issue = ClangFormatIssue('test/dummy/third_party.c', 10, 1, mock_revision)
assert not issue.is_publishable()