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

Commit

Permalink
staticanalysis/bot: Do not publish clang-format issues on third party,
Browse files Browse the repository at this point in the history
…fixes #1735.
  • Loading branch information
Bastien Abadie committed Dec 7, 2018
1 parent 1954440 commit 97b3856
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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()

0 comments on commit 97b3856

Please sign in to comment.