Skip to content

Commit 8097c64

Browse files
committed
SLCORE-198 Workaround for 10k limit
Fetch RESOLVED issues in priority, since issue suppression is more important than synchronization of severity/type/creation date
1 parent ea3abcf commit 8097c64

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

core/src/main/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloader.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ private static void copyTextRangeFromWs(Location.Builder locationBuilder, Sonarl
153153
}
154154

155155
private static String getIssuesUrl(String key) {
156-
return "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + StringUtils.urlEncode(key);
156+
// As a small workaround to the 10k limit, we sort on status, descending, in order to have resolved issues first (FP/WF)
157+
return "/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&s=STATUS&asc=false&componentKeys="
158+
+ StringUtils.urlEncode(key);
157159
}
158160
}

core/src/test/java/org/sonarsource/sonarlint/core/container/connected/update/IssueDownloaderTests.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ void test_download_one_issue() throws IOException {
8888
response.writeTo(byteStream);
8989
try (InputStream inputStream = new ByteArrayInputStream(byteStream.toByteArray())) {
9090
WsClientTestUtils.addResponse(wsClient,
91-
"/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + key + "&ps=500&p=1", inputStream);
91+
"/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&s=STATUS&asc=false&componentKeys=" + key + "&ps=500&p=1",
92+
inputStream);
9293
}
9394
}
9495

@@ -134,7 +135,8 @@ void test_download_no_issues() throws IOException {
134135
response.writeTo(byteStream);
135136
try (InputStream inputStream = new ByteArrayInputStream(byteStream.toByteArray())) {
136137
WsClientTestUtils.addResponse(wsClient,
137-
"/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + key + "&ps=500&p=1", inputStream);
138+
"/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&s=STATUS&asc=false&componentKeys=" + key + "&ps=500&p=1",
139+
inputStream);
138140
}
139141
}
140142

@@ -148,7 +150,7 @@ void test_fail_other_codes() throws IOException {
148150
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
149151
String key = "dummyKey";
150152
WsClientTestUtils.addFailedResponse(wsClient,
151-
"/api/issues/search.protobuf?statuses=OPEN,CONFIRMED,REOPENED,RESOLVED&types=CODE_SMELL,BUG,VULNERABILITY&componentKeys=" + key + "&ps=500&p=1", 503, "");
153+
"/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, "");
152154

153155
IssueDownloader issueDownloader = new IssueDownloader(wsClient, issueStorePaths);
154156
IllegalStateException thrown = assertThrows(IllegalStateException.class, () -> issueDownloader.download(key, projectConfiguration, PROGRESS));

0 commit comments

Comments
 (0)