Skip to content
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
17 changes: 17 additions & 0 deletions sonar/branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def export(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr:
:return: The branch new code period definition
:rtype: str
"""
from sonar import issues

log.debug("Exporting %s", str(self))
data = {settings.NEW_CODE_PERIOD: self.new_code()}
if self.is_main():
Expand All @@ -238,6 +240,21 @@ def export(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr:
loc_distrib = {m.split("=")[0]: int(m.split("=")[1]) for m in lang_distrib.split(";")}
loc_distrib["total"] = self.loc()
data["ncloc"] = loc_distrib
if export_settings["MODE"] == "MIGRATION":
tpissues = self.count_third_party_issues()
issue_data = {"thirdParty": tpissues if len(tpissues) > 0 else 0}
if self.endpoint.version() >= (10, 0, 0):
issue_data["falsePositives"] = issues.count(
self.endpoint, components=self.concerned_object.key, branch=self.name, issueStatuses="FALSE_POSITIVE"
)
issue_data["accepted"] = issues.count(self.endpoint, components=self.concerned_object.key, branch=self.name, issueStatuses="ACCEPTED")
else:
issue_data["falsePositives"] = issues.count(
self.endpoint, componentKeys=self.concerned_object.key, branch=self.name, resolutions="FALSE-POSITIVE"
)
issue_data["wontFix"] = issues.count(self.endpoint, componentKeys=self.concerned_object.key, branch=self.name, resolutions="WONTFIX")
data["issues"] = issue_data
log.debug("%s has these notable issues %s", str(self), str(data["issues"]))
data = util.remove_nones(data)
return None if len(data) == 0 else data

Expand Down
14 changes: 12 additions & 2 deletions sonar/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
:return: All project configuration settings
:rtype: dict
"""
from sonar import issues

log.info("Exporting %s", str(self))
try:
json_data = self._json.copy()
Expand Down Expand Up @@ -994,8 +996,16 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
"lastTaskWarnings": last_task.warnings(),
"taskHistory": [t._json for t in self.task_history()],
}
json_data["thirdPartyIssues"] = self.count_third_party_issues()
log.debug("%s has %d 3rd party issues", str(self), sum(v for v in json_data["thirdPartyIssues"].values()))
tpissues = self.count_third_party_issues()
issue_data = {"thirdParty": tpissues if len(tpissues) > 0 else 0}
if self.endpoint.version() >= (10, 0, 0):
issue_data["falsePositives"] = issues.count(self.endpoint, components=self.key, issueStatuses="FALSE_POSITIVE")
issue_data["accepted"] = issues.count(self.endpoint, components=self.key, issueStatuses="ACCEPTED")
else:
issue_data["falsePositives"] = issues.count(self.endpoint, componentKeys=self.key, resolutions="FALSE-POSITIVE")
issue_data["wontFix"] = issues.count(self.endpoint, componentKeys=self.key, resolutions="WONTFIX")
json_data["issues"] = issue_data
log.debug("%s has these notable issues %s", str(self), str(json_data["issues"]))

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