diff --git a/core/src/main/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloader.java b/core/src/main/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloader.java index c044b88f6b..74760933d5 100644 --- a/core/src/main/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloader.java +++ b/core/src/main/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloader.java @@ -153,6 +153,8 @@ private static void copyTextRangeFromWs(Location.Builder locationBuilder, Sonarl } private static String getIssuesUrl(String key) { - return "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + StringUtils.urlEncode(key); + // As a small workaround to the 10k limit, we sort on status, descending, in order to have resolved issues first (FP/WF) + return "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&s=STATUS&asc=false&componentKeys=" + + StringUtils.urlEncode(key); } } diff --git a/core/src/test/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloaderTests.java b/core/src/test/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloaderTests.java index 1f0c869a12..187480a8e5 100644 --- a/core/src/test/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloaderTests.java +++ b/core/src/test/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloaderTests.java @@ -88,7 +88,8 @@ void test_download_one_issue() throws IOException { response.writeTo(byteStream); try (InputStream inputStream = new ByteArrayInputStream(byteStream.toByteArray())) { WsClientTestUtils.addResponse(wsClient, - "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + key + "&ps=500&p=1", inputStream); + "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&s=STATUS&asc=false&componentKeys=" + key + "&ps=500&p=1", + inputStream); } } @@ -134,7 +135,8 @@ void test_download_no_issues() throws IOException { response.writeTo(byteStream); try (InputStream inputStream = new ByteArrayInputStream(byteStream.toByteArray())) { WsClientTestUtils.addResponse(wsClient, - "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + key + "&ps=500&p=1", inputStream); + "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&s=STATUS&asc=false&componentKeys=" + key + "&ps=500&p=1", + inputStream); } } @@ -148,7 +150,7 @@ void test_fail_other_codes() throws IOException { SonarLintWsClient wsClient = WsClientTestUtils.createMock(); String key = "dummyKey"; WsClientTestUtils.addFailedResponse(wsClient, - "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + key + "&ps=500&p=1", 503, ""); + "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&s=STATUS&asc=false&componentKeys=" + key + "&ps=500&p=1", 503, ""); IssueDownloader issueDownloader = new IssueDownloader(wsClient, issueStorePaths); IllegalStateException thrown = assertThrows(IllegalStateException.class, () -> issueDownloader.download(key, projectConfiguration, PROGRESS));