Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONARGO-80 Update sonarlint-core dependency #50

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
[versions]
slang-dependencies = "1.17.0.6351"
analyzer-commons = "2.16.0.3141"
plugin-api = "10.10.0.2391"
sonarqube = "10.0.0.68432"
plugin-api = "10.11.0.2468"
sonarqube = "24.12.0.100206"
orchestrator = "5.1.0.2254"
sonarlint = "9.0.0.74282"
sonarlint = "10.11.2.79730"
minimal-json = "0.9.5"
mockito-core = "5.13.0"
assertj-core = "3.26.3"
junit-jupiter = "5.11.0"
# slf4j is provided by SQ, SC or SL, should be aligned with sonar-plugin-api in integration tests
slf4j-api = "1.7.30"
xerces = "2.12.2"
awaitility = "4.2.2"

[libraries]
sonar-plugin-api = { group = "org.sonarsource.api.plugin", name = "sonar-plugin-api", version.ref = "plugin-api" }
Expand All @@ -24,6 +26,8 @@ sonar-plugin-api-test-fixtures = { group = "org.sonarsource.api.plugin", name =
sonar-plugin-api-impl = { group = "org.sonarsource.sonarqube", name = "sonar-plugin-api-impl", version.ref = "sonarqube" }
sonar-orchestrator-junit5 = { group = "org.sonarsource.orchestrator", name = "sonar-orchestrator-junit5", version.ref = "orchestrator" }
sonarlint-core = { group = "org.sonarsource.sonarlint.core", name = "sonarlint-core", version.ref = "sonarlint" }
sonar-lint-rpc-java-client = { module = "org.sonarsource.sonarlint.core:sonarlint-rpc-java-client", version.ref = "sonarlint" }
sonar-lint-rpc-impl = { module = "org.sonarsource.sonarlint.core:sonarlint-rpc-impl", version.ref = "sonarlint" }
sonar-ws = { group = "org.sonarsource.sonarqube", name = "sonar-ws", version.ref = "sonarqube" }
slang-antlr = { group = "org.sonarsource.slang", name = "slang-antlr", version.ref = "slang-dependencies" }
slang-testing = { group = "org.sonarsource.slang", name = "slang-testing", version.ref = "slang-dependencies" }
Expand All @@ -32,3 +36,5 @@ assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "as
junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit-jupiter" }
junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit-jupiter" }
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j-api" }
xerces = { group = "xerces", name = "xercesImpl", version.ref = "xerces" }
awaitility = { module = "org.awaitility:awaitility", version.ref = "awaitility"}
4 changes: 4 additions & 0 deletions its/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ plugins {

dependencies {
"integrationTestImplementation"(libs.slf4j.api)
"integrationTestImplementation"(libs.xerces)
"integrationTestImplementation"(project(":sonar-go-plugin", configuration = "shadow"))
"integrationTestImplementation"(libs.sonar.analyzer.commons)
"integrationTestImplementation"(libs.sonar.ws)
"integrationTestImplementation"(libs.assertj.core)
"integrationTestImplementation"(libs.sonarlint.core)
"integrationTestImplementation"(libs.sonar.lint.rpc.java.client)
"integrationTestImplementation"(libs.sonar.lint.rpc.impl)
"integrationTestImplementation"(libs.awaitility)
"integrationTestImplementation"(libs.sonar.orchestrator.junit5) {
exclude("ch.qos.logback", "logback-classic")
exclude("org.slf4j", "slf4j-api")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
/*
* SonarSource Go
* Copyright (C) 2018-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Sonar Source-Available License for more details.
*
* You should have received a copy of the Sonar Source-Available License
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
package org.sonarsource.slang;

import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import org.sonarsource.sonarlint.core.rpc.client.ConfigScopeNotFoundException;
import org.sonarsource.sonarlint.core.rpc.client.ConnectionNotFoundException;
import org.sonarsource.sonarlint.core.rpc.client.SonarLintCancelChecker;
import org.sonarsource.sonarlint.core.rpc.client.SonarLintRpcClientDelegate;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.config.binding.BindingSuggestionDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.TaintVulnerabilityDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.RawIssueDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.NoBindingSuggestionFoundParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.ConnectionSuggestionDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.event.DidReceiveServerHotspotEvent;
import org.sonarsource.sonarlint.core.rpc.protocol.client.fix.FixSuggestionDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.hotspot.HotspotDetailsDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.http.GetProxyPasswordAuthenticationResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.client.http.ProxyDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.http.X509CertificateDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.IssueDetailsDto;
import org.sonarsource.sonarlint.core.rpc.protocol.client.log.LogParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.message.MessageType;
import org.sonarsource.sonarlint.core.rpc.protocol.client.message.ShowSoonUnsupportedMessageParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.progress.ReportProgressParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.progress.StartProgressParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.smartnotification.ShowSmartNotificationParams;
import org.sonarsource.sonarlint.core.rpc.protocol.client.telemetry.TelemetryClientLiveAttributesResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.common.ClientFileDto;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Either;
import org.sonarsource.sonarlint.core.rpc.protocol.common.TokenDto;
import org.sonarsource.sonarlint.core.rpc.protocol.common.UsernamePasswordDto;

/**
* Inspiration: <a href="https://github.com/SonarSource/sonarlint-core/blob/master/its/tests/src/test/java/its/MockSonarLintRpcClientDelegate.java">
* sonarlint-core MockSonarLintRpcClientDelegate.java</a>
*/
public class MockSonarLintRpcClientDelegate implements SonarLintRpcClientDelegate {

private final Map<String, List<RawIssueDto>> raisedIssues = new HashMap<>();

public List<RawIssueDto> getRaisedIssues(String configurationScopeId) {
var issues = raisedIssues.get(configurationScopeId);
return issues != null ? issues : List.of();
}

public Map<String, List<RawIssueDto>> getRaisedIssues() {
return raisedIssues;
}

@Override
public void didRaiseIssue(String configurationScopeId, UUID analysisId, RawIssueDto rawIssue) {
raisedIssues.computeIfAbsent(configurationScopeId, k -> new ArrayList<>()).add(rawIssue);
}

@Override
public void suggestBinding(Map<String, List<BindingSuggestionDto>> suggestionsByConfigScope) {

}

@Override
public void suggestConnection(Map<String, List<ConnectionSuggestionDto>> suggestionsByConfigScope) {

}

@Override
public void openUrlInBrowser(URL url) {

}

@Override
public void showMessage(MessageType type, String text) {

}

@Override
public void log(LogParams params) {
System.out.println(params);
}

@Override
public void showSoonUnsupportedMessage(ShowSoonUnsupportedMessageParams params) {

}

@Override
public void showSmartNotification(ShowSmartNotificationParams params) {

}

@Override
public String getClientLiveDescription() {
return "";
}

@Override
public void showHotspot(String configurationScopeId, HotspotDetailsDto hotspotDetails) {

}

@Override
public void showIssue(String configurationScopeId, IssueDetailsDto issueDetails) {

}

@Override
public void showFixSuggestion(String configurationScopeId, String issueKey, FixSuggestionDto fixSuggestion) {

}

@Override
public AssistCreatingConnectionResponse assistCreatingConnection(AssistCreatingConnectionParams params, SonarLintCancelChecker cancelChecker) throws CancellationException {
throw new CancellationException("Unsupported in ITS");
}

@Override
public AssistBindingResponse assistBinding(AssistBindingParams params, SonarLintCancelChecker cancelChecker) throws CancellationException {
throw new CancellationException("Unsupported in ITS");
}

@Override
public void startProgress(StartProgressParams params) throws UnsupportedOperationException {

}

@Override
public void reportProgress(ReportProgressParams params) {

}

@Override
public void didSynchronizeConfigurationScopes(Set<String> configurationScopeIds) {

}

@Override
public Either<TokenDto, UsernamePasswordDto> getCredentials(String connectionId) throws ConnectionNotFoundException {
throw new ConnectionNotFoundException();
}

@Override
public List<ProxyDto> selectProxies(URI uri) {
return List.of(ProxyDto.NO_PROXY);
}

@Override
public GetProxyPasswordAuthenticationResponse getProxyPasswordAuthentication(String host, int port, String protocol, String prompt, String scheme, URL targetHost) {
return new GetProxyPasswordAuthenticationResponse("", "");
}

@Override
public boolean checkServerTrusted(List<X509CertificateDto> chain, String authType) {
return false;
}

@Override
public void didReceiveServerHotspotEvent(DidReceiveServerHotspotEvent params) {

}

@Override
public String matchSonarProjectBranch(String configurationScopeId, String mainBranchName, Set<String> allBranchesNames, SonarLintCancelChecker cancelChecker)
throws ConfigScopeNotFoundException {
return mainBranchName;
}

public boolean matchProjectBranch(String configurationScopeId, String branchNameToMatch, SonarLintCancelChecker cancelChecker) throws ConfigScopeNotFoundException {
return true;
}

@Override
public void didChangeMatchedSonarProjectBranch(String configScopeId, String newMatchedBranchName) {

}

@Override
public TelemetryClientLiveAttributesResponse getTelemetryLiveAttributes() {
System.err.println("Telemetry should be disabled in ITs");
throw new CancellationException("Telemetry should be disabled in ITs");
}

@Override
public void didChangeTaintVulnerabilities(String configurationScopeId, Set<UUID> closedTaintVulnerabilityIds, List<TaintVulnerabilityDto> addedTaintVulnerabilities,
List<TaintVulnerabilityDto> updatedTaintVulnerabilities) {

}

@Override
public List<ClientFileDto> listFiles(String configScopeId) {
return List.of();
}

@Override
public void noBindingSuggestionFound(NoBindingSuggestionFoundParams params) {
}

@Override
public void didChangeAnalysisReadiness(Set<String> configurationScopeIds, boolean areReadyForAnalysis) {

}

public void clear() {
raisedIssues.clear();
}

}
Loading
Loading