Skip to content

Commit 4f75f87

Browse files
authored
No-multithread-when-counting (#1348)
* Decreased info log in debug * Fixes #1344 * Add log on end of project export * Fix test
1 parent b59e5dd commit 4f75f87

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

sonar/hotspots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def search(endpoint: pf.Platform, filters: types.ApiParams = None) -> dict[str,
391391
for inline_filters in filters_iterations:
392392
p = 1
393393
inline_filters["ps"] = ps
394-
log.info("Searching hotspots with sanitized filters %s", str(inline_filters))
394+
log.debug("Searching hotspots with sanitized filters %s", str(inline_filters))
395395
while True:
396396
inline_filters["p"] = p
397397
try:

sonar/issues.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,9 @@ def get_newest_issue(endpoint: pf.Platform, params: ApiParams = None) -> Union[d
823823
def count(endpoint: pf.Platform, **kwargs) -> int:
824824
"""Returns number of issues of a search"""
825825
params = {} if not kwargs else kwargs.copy()
826-
params["ps"] = 1
827-
try:
828-
nbr_issues = len(search(endpoint=endpoint, params=params))
829-
except TooManyIssuesError as e:
830-
nbr_issues = e.nbr_issues
826+
filters = pre_search_filters(endpoint=endpoint, params=params)
827+
filters["ps"] = 1
828+
nbr_issues = json.loads(endpoint.get(Issue.SEARCH_API, params=filters).text)["paging"]["total"]
831829
log.debug("Count issues with filters %s returned %d issues", str(kwargs), nbr_issues)
832830
return nbr_issues
833831

sonar/projects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
10241024
else:
10251025
log.critical("HTTP error %s while exporting %s, export of this project skipped", str(e), str(self))
10261026
json_data = {}
1027+
log.info("Exporting %s done", str(self))
10271028
return util.remove_nones(json_data)
10281029

10291030
def new_code(self) -> str:

test/test_migration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_migration() -> None:
9494
assert p["branches"]["master"]["hotspots"]["acknowledged"] == 0
9595

9696
p = json_config["projects"]["checkstyle-issues"]
97-
assert len(p["branches"]["issues"]["thirdParty"]) > 0
97+
assert len(p["branches"]["main"]["issues"]["thirdParty"]) > 0
9898

9999
assert json_config["projects"]["demo:gitlab-ci-maven"]["detectedCi"] == "GitLab CI"
100100
assert json_config["projects"]["demo:gitlab-actions-cli"]["detectedCi"] == "Github Actions"

0 commit comments

Comments
 (0)