Skip to content

Commit

Permalink
SLCORE-198 Workaround for 10k limit
Browse files Browse the repository at this point in the history
Fetch RESOLVED issues in priority, since issue suppression is more important
than synchronization of severity/type/creation date
  • Loading branch information
henryju committed Feb 2, 2021
1 parent ea3abcf commit 8097c64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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));
Expand Down

0 comments on commit 8097c64

Please sign in to comment.