Bug 1568771 - Output paths relative to repository in ./mach static-analysis check-coverity, r=andi

Differential Revision: https://phabricator.services.mozilla.com/D39306

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bastien Abadie 2019-07-30 06:44:52 +00:00
Родитель 11ff2f61f3
Коммит cd3055975d
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -405,6 +405,13 @@ class StaticAnalysis(MachCommandBase):
def dump_cov_artifact(self, cov_results, source, output):
# Parse Coverity json into structured issues
def relpath(path):
'''Build path relative to repository root'''
if path.startswith(self.topsrcdir):
return os.path.relpath(path, self.topsrcdir)
return path
with open(cov_results) as f:
result = json.load(f)
@ -435,7 +442,7 @@ class StaticAnalysis(MachCommandBase):
# Embed all events into extra message
for event in issue['events']:
dict_issue['extra']['stack'].append(
{'file_path': event['strippedFilePathname'],
{'file_path': relpath(event['strippedFilePathname']),
'line_number': event['lineNumber'],
'path_type': event['eventTag'],
'description': event['eventDescription']})
@ -453,6 +460,7 @@ class StaticAnalysis(MachCommandBase):
issue['strippedMainEventFilePathname'])
)
continue
path = relpath(path)
if path in files_list:
files_list[path]['warnings'].append(build_element(issue))
else: