Skip to content

Commit 31347b3

Browse files
committed
Refactoring
1 parent 7c49b72 commit 31347b3

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

sonar/components.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ def __init__(self, endpoint: pf.Platform, key: str, data: types.ApiPayload = Non
6666
self.reload(data)
6767

6868
def reload(self, data: types.ApiPayload) -> Component:
69-
log.debug("Reloading %s with %s", str(self), utilities.json_dump(data))
70-
if not self.sq_json:
71-
self.sq_json = {}
72-
self.sq_json.update(data)
69+
"""Loads a SonarQube API JSON payload in a Component"""
70+
super().reload(data)
7371
if "name" in data:
7472
self.name = data["name"]
7573
if "visibility" in data:

sonar/sqobject.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,10 @@ def clear_cache(cls, endpoint: Optional[object] = None) -> None:
8989
except AttributeError:
9090
pass
9191

92-
def reload(self, data: types.ObjectJsonRepr) -> None:
93-
"""Reload a Sonar object with its JSON representation"""
94-
if self.sq_json is None:
95-
self.sq_json = data
96-
else:
97-
self.sq_json.update(data)
92+
def reload(self, data: types.ApiPayload) -> None:
93+
"""Loads a SonarQube API JSON payload in a SonarObject"""
94+
log.debug("%s: Reloading with %s", str(self), utilities.json_dump(data))
95+
self.sq_json = (self.sq_json or {}) | data
9896

9997
def base_url(self, local: bool = True) -> str:
10098
"""Returns the platform base URL"""

0 commit comments

Comments
 (0)