Skip to content

Commit 494f8ac

Browse files
authored
Merge pull request #1319 from okorach:migration-get-fp-wf-accepted
Fixes #1303
2 parents 0f59c1d + d7db42e commit 494f8ac

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

sonar/branches.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ def export(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr:
220220
:return: The branch new code period definition
221221
:rtype: str
222222
"""
223+
from sonar import issues
224+
223225
log.debug("Exporting %s", str(self))
224226
data = {settings.NEW_CODE_PERIOD: self.new_code()}
225227
if self.is_main():
@@ -238,6 +240,21 @@ def export(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr:
238240
loc_distrib = {m.split("=")[0]: int(m.split("=")[1]) for m in lang_distrib.split(";")}
239241
loc_distrib["total"] = self.loc()
240242
data["ncloc"] = loc_distrib
243+
if export_settings["MODE"] == "MIGRATION":
244+
tpissues = self.count_third_party_issues()
245+
issue_data = {"thirdParty": tpissues if len(tpissues) > 0 else 0}
246+
if self.endpoint.version() >= (10, 0, 0):
247+
issue_data["falsePositives"] = issues.count(
248+
self.endpoint, components=self.concerned_object.key, branch=self.name, issueStatuses="FALSE_POSITIVE"
249+
)
250+
issue_data["accepted"] = issues.count(self.endpoint, components=self.concerned_object.key, branch=self.name, issueStatuses="ACCEPTED")
251+
else:
252+
issue_data["falsePositives"] = issues.count(
253+
self.endpoint, componentKeys=self.concerned_object.key, branch=self.name, resolutions="FALSE-POSITIVE"
254+
)
255+
issue_data["wontFix"] = issues.count(self.endpoint, componentKeys=self.concerned_object.key, branch=self.name, resolutions="WONTFIX")
256+
data["issues"] = issue_data
257+
log.debug("%s has these notable issues %s", str(self), str(data["issues"]))
241258
data = util.remove_nones(data)
242259
return None if len(data) == 0 else data
243260

sonar/projects.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
953953
:return: All project configuration settings
954954
:rtype: dict
955955
"""
956+
from sonar import issues
957+
956958
log.info("Exporting %s", str(self))
957959
try:
958960
json_data = self._json.copy()
@@ -994,8 +996,16 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
994996
"lastTaskWarnings": last_task.warnings(),
995997
"taskHistory": [t._json for t in self.task_history()],
996998
}
997-
json_data["thirdPartyIssues"] = self.count_third_party_issues()
998-
log.debug("%s has %d 3rd party issues", str(self), sum(v for v in json_data["thirdPartyIssues"].values()))
999+
tpissues = self.count_third_party_issues()
1000+
issue_data = {"thirdParty": tpissues if len(tpissues) > 0 else 0}
1001+
if self.endpoint.version() >= (10, 0, 0):
1002+
issue_data["falsePositives"] = issues.count(self.endpoint, components=self.key, issueStatuses="FALSE_POSITIVE")
1003+
issue_data["accepted"] = issues.count(self.endpoint, components=self.key, issueStatuses="ACCEPTED")
1004+
else:
1005+
issue_data["falsePositives"] = issues.count(self.endpoint, componentKeys=self.key, resolutions="FALSE-POSITIVE")
1006+
issue_data["wontFix"] = issues.count(self.endpoint, componentKeys=self.key, resolutions="WONTFIX")
1007+
json_data["issues"] = issue_data
1008+
log.debug("%s has these notable issues %s", str(self), str(json_data["issues"]))
9991009

10001010
settings_dict = settings.get_bulk(endpoint=self.endpoint, component=self, settings_list=settings_list, include_not_set=False)
10011011
# json_data.update({s.to_json() for s in settings_dict.values() if include_inherited or not s.inherited})

0 commit comments

Comments
 (0)