Skip to content

Commit

Permalink
SLVSCODE-927 use rebranded SLCORE version
Browse files Browse the repository at this point in the history
  • Loading branch information
sophio-japharidze-sonarsource committed Nov 19, 2024
1 parent 8837e9a commit f05d6ce
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<properties>
<jdk.min.version>17</jdk.min.version>
<sonarlint.core.version>10.10.0.79500</sonarlint.core.version>
<sonarlint.core.version>10.10.0.79572</sonarlint.core.version>
<!-- Version used by Xodus -->
<kotlin.version>1.6.10</kotlin.version>
<!-- analyzers used for tests -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,6 @@ public void mockSonarQube() {
Issues.TaintVulnerabilityPullQueryTimestamp.newBuilder()
.setQueryTimestamp(CURRENT_TIME)
.build());
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=inFolderToo.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=analysisConnected_find_hotspot.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());
Expand All @@ -237,24 +234,6 @@ public void mockSonarQube() {
"/api/issues/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST,
Issues.IssuesPullQueryTimestamp.newBuilder()
.setQueryTimestamp(CURRENT_TIME)
.build(),
Issues.IssueLite.newBuilder()
.setKey("xyz")
.setRuleKey(PYTHON_S1481)
.setType(Common.RuleType.CODE_SMELL)
.setUserSeverity(Common.Severity.BLOCKER)
.setMainLocation(Issues.Location.newBuilder()
.setFilePath("inFolderToo.py")
.setMessage("Remove the unused local variable \"toto\".")
.setTextRange(Issues.TextRange.newBuilder()
.setStartLine(1)
.setStartLineOffset(2)
.setEndLine(1)
.setEndLineOffset(6)
.setHash("f71dbe52628a3f83a77ab494817525c6")
.build())
.build())
.setClosed(false)
.build());
client.clearHotspotsAndIssuesAndConfigScopeReadiness();
}
Expand Down Expand Up @@ -395,6 +374,9 @@ void analysisConnected_find_tracked_hotspot_after_sq_10_1() {
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=myProject&files=hotspot.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=myProject&files=analysisConnected_no_matching_server_issues.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());
mockWebServerExtension.addProtobufResponse(
"/api/rules/show.protobuf?key=python:S1313",
Rules.ShowResponse.newBuilder()
Expand Down Expand Up @@ -564,7 +546,7 @@ void analysisConnected_no_matching_server_issues() {
.build());

addConfigScope(folder1BaseDir.toUri().toString());
var uriInFolder = folder1BaseDir.resolve("inFolder.py").toUri().toString();
var uriInFolder = folder1BaseDir.resolve("hotspot.py").toUri().toString();
didOpen(uriInFolder, "python", "def foo():\n toto = 0\n plouf = 0\n");

awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uriInFolder))
Expand Down Expand Up @@ -614,11 +596,37 @@ void analysisConnected_matching_server_issues() throws Exception {
.setParameter("9.2")
.build())
.build());
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=analysisConnected_matching_server_issues.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());
mockWebServerExtension.addProtobufResponseDelimited(
"/api/issues/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST,
Issues.IssuesPullQueryTimestamp.newBuilder()
.setQueryTimestamp(CURRENT_TIME)
.build(),
Issues.IssueLite.newBuilder()
.setKey("xyz")
.setRuleKey(PYTHON_S1481)
.setType(Common.RuleType.CODE_SMELL)
.setUserSeverity(Common.Severity.BLOCKER)
.setMainLocation(Issues.Location.newBuilder()
.setFilePath("analysisConnected_matching_server_issues.py")
.setMessage("Remove the unused local variable \"toto\".")
.setTextRange(Issues.TextRange.newBuilder()
.setStartLine(1)
.setStartLineOffset(2)
.setEndLine(1)
.setEndLineOffset(6)
.setHash("f71dbe52628a3f83a77ab494817525c6")
.build())
.build())
.setClosed(false)
.build());

addConfigScope(folder1BaseDir.toUri().toString());
lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "master"));

var uriInFolder = folder1BaseDir.resolve("inFolderToo.py").toUri().toString();
var uriInFolder = folder1BaseDir.resolve("analysisConnected_matching_server_issues.py").toUri().toString();
didOpen(uriInFolder, "python", "def foo():\n toto = 0\n plouf = 0\n");

awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uriInFolder))
Expand Down Expand Up @@ -814,19 +822,18 @@ void checkLocalDetectionSupportedNotBound() throws ExecutionException, Interrupt

@Test
void shouldChangeIssueStatus() {
var issueKey = "xyz";

mockWebServerExtension.addResponse("/api/issues/do_transition", new MockResponse().setResponseCode(200));
mockWebServerExtension.addResponse("/api/issues/anticipated_transitions?projectKey=myProject", new MockResponse().setResponseCode(200));
mockWebServerExtension.addResponse("/api/issues/add_comment", new MockResponse().setResponseCode(200));
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=myProject&files=inFolderToo.py&branch=master&ps=500&p=1",
"/api/hotspots/search.protobuf?projectKey=myProject&files=hotspot.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());

addConfigScope(folder1BaseDir.toUri().toString());
awaitUntilAsserted(() -> assertThat(client.logs.stream().anyMatch(messageParams -> messageParams.getMessage().contains("Synchronizing project branches for project 'myProject'"))).isTrue());
lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "some/branch/name"));

var fileUri = folder1BaseDir.resolve("inFolderToo.py").toUri().toString();
var fileUri = folder1BaseDir.resolve("hotspot.py").toUri().toString();
var content = "def foo():\n toto = 0\n plouf = 0\n";
didOpen(fileUri, "python", content);

Expand All @@ -837,6 +844,8 @@ void shouldChangeIssueStatus() {
tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning),
tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning)));

var issueKey = ((JsonObject) client.getDiagnostics(fileUri).get(0).getData()).get("entryKey").getAsString();

lsProxy.changeIssueStatus(new SonarLintExtendedLanguageServer.ChangeIssueStatusParams(folder1BaseDir.toUri().toString(), issueKey,
"False positive", fileUri, "clever comment", false));

Expand All @@ -856,14 +865,14 @@ void shouldNotChangeIssueStatus() {
mockWebServerExtension.addResponse("/api/issues/do_transition", new MockResponse().setResponseCode(400));
mockWebServerExtension.addResponse("/api/issues/add_comment", new MockResponse().setResponseCode(400));
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=myProject&files=inFolderToo.py&branch=master&ps=500&p=1",
"/api/hotspots/search.protobuf?projectKey=myProject&files=shouldNotChangeIssueStatus.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());

addConfigScope(folder1BaseDir.toUri().toString());
awaitUntilAsserted(() -> assertThat(client.logs.stream().anyMatch(messageParams -> messageParams.getMessage().contains("Synchronizing project branches for project 'myProject'"))).isTrue());
lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "some/branch/name"));

var fileUri = folder1BaseDir.resolve("inFolderToo.py").toUri().toString();
var fileUri = folder1BaseDir.resolve("shouldNotChangeIssueStatus.py").toUri().toString();
var content = "def foo():\n toto = 0\n plouf = 0\n";
didOpen(fileUri, "python", content);

Expand Down Expand Up @@ -1179,6 +1188,32 @@ void change_issue_status_permission_check() throws ExecutionException, Interrupt
.build())
.build())
.build());
mockWebServerExtension.addProtobufResponse(
"/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=change_issue_status_permission_check.py&branch=master&ps=500&p=1",
Hotspots.SearchWsResponse.newBuilder().build());
mockWebServerExtension.addProtobufResponseDelimited(
"/api/issues/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST,
Issues.IssuesPullQueryTimestamp.newBuilder()
.setQueryTimestamp(CURRENT_TIME)
.build(),
Issues.IssueLite.newBuilder()
.setKey("xyz")
.setRuleKey(PYTHON_S1481)
.setType(Common.RuleType.CODE_SMELL)
.setUserSeverity(Common.Severity.BLOCKER)
.setMainLocation(Issues.Location.newBuilder()
.setFilePath("change_issue_status_permission_check.py")
.setMessage("Remove the unused local variable \"toto\".")
.setTextRange(Issues.TextRange.newBuilder()
.setStartLine(1)
.setStartLineOffset(2)
.setEndLine(1)
.setEndLineOffset(6)
.setHash("f71dbe52628a3f83a77ab494817525c6")
.build())
.build())
.setClosed(false)
.build());

mockWebServerExtension.addResponse("/api/issues/do_transition", new MockResponse().setResponseCode(200));
mockWebServerExtension.addResponse("/api/issues/add_comment", new MockResponse().setResponseCode(200));
Expand Down

0 comments on commit f05d6ce

Please sign in to comment.