|
42 | 42 | from sonar.util import types |
43 | 43 |
|
44 | 44 | from sonar import exceptions, errcodes |
45 | | -from sonar import sqobject, components, qualitygates, qualityprofiles, tasks, settings, webhooks, devops, syncer |
| 45 | +from sonar import sqobject, components, qualitygates, qualityprofiles, rules, tasks, settings, webhooks, devops, syncer |
46 | 46 | import sonar.permissions.permissions as perms |
47 | 47 | from sonar import pull_requests, branches |
48 | 48 | import sonar.utilities as util |
@@ -783,6 +783,20 @@ def get_issues(self, filters: dict[str, str] = None) -> dict[str, object]: |
783 | 783 | findings_list = {**findings_list, **comp.get_issues()} |
784 | 784 | return findings_list |
785 | 785 |
|
| 786 | + def count_third_party_issues(self, filters: dict[str, str] = None) -> dict[str, int]: |
| 787 | + branches_or_prs = self.get_branches_and_prs(filters) |
| 788 | + if branches_or_prs is None: |
| 789 | + return super().count_third_party_issues(filters) |
| 790 | + issue_counts = {} |
| 791 | + for comp in branches_or_prs.values(): |
| 792 | + if not comp: |
| 793 | + continue |
| 794 | + for k, total in comp.count_third_party_issues(filters): |
| 795 | + if k not in issue_counts: |
| 796 | + issue_counts[k] = 0 |
| 797 | + issue_counts[k] += total |
| 798 | + return issue_counts |
| 799 | + |
786 | 800 | def __sync_community(self, another_project: object, sync_settings: types.ConfigSettings) -> tuple[list[dict[str, str]], dict[str, int]]: |
787 | 801 | """Syncs 2 projects findings on a community edition""" |
788 | 802 | report, counters = [], {} |
@@ -978,6 +992,8 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str, |
978 | 992 | "lastTaskWarnings": last_task.warnings(), |
979 | 993 | "taskHistory": [t._json for t in self.task_history()], |
980 | 994 | } |
| 995 | + json_data["thirdPartyIssues"] = self.count_third_party_issues() |
| 996 | + log.info("%s has %d 3rd party issues", str(self), sum(v for v in json_data["thirdPartyIssues"].values())) |
981 | 997 |
|
982 | 998 | settings_dict = settings.get_bulk(endpoint=self.endpoint, component=self, settings_list=settings_list, include_not_set=False) |
983 | 999 | # json_data.update({s.to_json() for s in settings_dict.values() if include_inherited or not s.inherited}) |
|
0 commit comments