Skip to content

Commit 35fe445

Browse files
committed
Use common fields conversion
1 parent 988f50b commit 35fe445

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

sonar/qualitygates.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
from sonar.audit.rules import get_rule, RuleId
4040
from sonar.audit.problem import Problem
41+
from sonar.util import common_json_helper
4142

4243

4344
__MAX_ISSUES_SHOULD_BE_ZERO = "Any numeric threshold on number of issues should be 0 or should be removed from QG conditions"
@@ -565,4 +566,5 @@ def search_by_name(endpoint: pf.Platform, name: str) -> dict[str, QualityGate]:
565566

566567
def convert_qgs_json(old_json: dict[str, Any]) -> dict[str, Any]:
567568
"""Converts the sonar-config quality gates old JSON report format to the new one"""
569+
old_json = common_json_helper.convert_common_fields(old_json, with_permissions=False)
568570
return util.dict_to_list(old_json, "name")

sonar/util/platform_helper.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from typing import Any
2323
from sonar import settings
2424
from sonar import utilities as util
25+
from sonar.util import common_json_helper
2526

2627
_PERM_TPL_IMPORTABLE_PROPERTIES = ("name", "description", "pattern", "defaultFor", "permissions")
2728

@@ -47,8 +48,7 @@ def convert_basics_json(old_json: dict[str, Any]) -> dict[str, Any]:
4748

4849

4950
def convert_template_json(json_data: dict[str, Any], full: bool = False) -> dict[str, Any]:
50-
if "permissions" in json_data:
51-
json_data["permissions"] = util.perms_to_list(json_data["permissions"])
51+
json_data = common_json_helper.convert_common_fields(json_data)
5252
return util.remove_nones(util.filter_export(json_data, _PERM_TPL_IMPORTABLE_PROPERTIES, full))
5353

5454

@@ -63,8 +63,9 @@ def convert_global_settings_json(old_json: dict[str, Any], full: bool = False) -
6363
new_json[settings.LANGUAGES_SETTINGS][k] = util.sort_list_by_key(util.dict_to_list(v, "key"), "key")
6464
new_json[settings.LANGUAGES_SETTINGS] = util.dict_to_list(dict(sorted(new_json[settings.LANGUAGES_SETTINGS].items())), "language", "settings")
6565
new_json[settings.DEVOPS_INTEGRATION] = util.dict_to_list(dict(sorted(old_json[settings.DEVOPS_INTEGRATION].items())), "key")
66-
new_json["permissions"] = util.perms_to_list(old_json["permissions"])
6766
for k, v in new_json["permissionTemplates"].items():
6867
new_json["permissionTemplates"][k] = convert_template_json(new_json["permissionTemplates"][k], full)
6968
new_json["permissionTemplates"] = util.dict_to_list(new_json["permissionTemplates"], "key")
70-
return new_json
69+
new_json = common_json_helper.convert_common_fields(new_json)
70+
71+
return util.order_dict(new_json, [*settings.CATEGORIES, "permissions", "permissionTemplates"])

0 commit comments

Comments
 (0)