Skip to content

Commit

Permalink
SLLS-231 Update to latest SLCORE 10.1 build
Browse files Browse the repository at this point in the history
  • Loading branch information
jblievremont committed Apr 18, 2024
1 parent fc20b6b commit 10fd1ba
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 36 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.1.0.77598</sonarlint.core.version>
<sonarlint.core.version>10.1.0.77680</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 @@ -356,7 +356,7 @@ public CompletableFuture<ShowRuleDescriptionParams> getShowRuleDescriptionParams
return backendServiceFacade.getBackendService().getEffectiveRuleDetails(workspaceFolder, ruleKey, ruleContextKey)
.thenApply(detailsResponse -> {
var ruleDetailsDto = detailsResponse.details();
return createShowRuleDescriptionParams(ruleDetailsDto, Collections.emptyMap(), ruleDetailsDto.getDescription(), ruleKey,
return createShowRuleDescriptionParams(ruleDetailsDto, Collections.emptyMap(), ruleDetailsDto.getDescription().getLsp4jEither(), ruleKey,
ruleContextKey);
}).exceptionally(e -> {
var message = "Can't show rule details for unknown rule with key: " + ruleKey;
Expand All @@ -369,7 +369,7 @@ public CompletableFuture<ShowRuleDescriptionParams> getShowRuleDescriptionParams
private void showStandaloneRuleDescription(String ruleKey, GetStandaloneRuleDescriptionResponse ruleDetails) {
var ruleDefinition = ruleDetails.getRuleDefinition();
var paramDetails = ruleDefinition.getParamsByKey();
var showRuleDescriptionParams = createShowRuleDescriptionParams(ruleDefinition, paramDetails, ruleDetails.getDescription(), ruleKey,
var showRuleDescriptionParams = createShowRuleDescriptionParams(ruleDefinition, paramDetails, ruleDetails.getDescription().getLsp4jEither(), ruleKey,
"");
client.showRuleDescription(showRuleDescriptionParams);
}
Expand Down Expand Up @@ -405,6 +405,7 @@ private static ImmutablePair<String, String> getCleanCodeAttributeAndCategory(@N
}

public void executeCommand(ExecuteCommandParams params, CancelChecker cancelToken) {
cancelToken.checkCanceled();
switch (params.getCommand()) {
case SONARLINT_QUICK_FIX_APPLIED:
telemetry.addQuickFixAppliedForRule(getAsString(params.getArguments().get(0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.lsp4j.MessageParams;
import org.eclipse.lsp4j.MessageType;
import org.eclipse.lsp4j.WorkspaceFolder;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcServer;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.DidChangeClientNodeJsPathParams;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.GetSupportedFilePatternsParams;
Expand Down Expand Up @@ -92,6 +91,7 @@
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.TrackWithServerIssuesResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.GetBindingSuggestionsResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.common.ClientFileDto;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Either;
import org.sonarsource.sonarlint.ls.SonarLintExtendedLanguageClient;
import org.sonarsource.sonarlint.ls.SonarLintExtendedLanguageServer;
import org.sonarsource.sonarlint.ls.connected.ProjectBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@
import org.eclipse.lsp4j.MessageParams;
import org.eclipse.lsp4j.MessageType;
import org.eclipse.lsp4j.ShowMessageRequestParams;
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
import org.eclipse.lsp4j.jsonrpc.CompletableFutures;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.jetbrains.annotations.NotNull;
import org.sonarsource.sonarlint.core.client.utils.ClientLogOutput;
import org.sonarsource.sonarlint.core.commons.HotspotReviewStatus;
import org.sonarsource.sonarlint.core.commons.SonarLintUserHome;
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;
Expand All @@ -83,6 +82,7 @@
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;
import org.sonarsource.sonarlint.ls.AnalysisScheduler;
Expand Down Expand Up @@ -256,7 +256,7 @@ public void showIssue(String folderUri, IssueDetailsDto issueDetails) {
}

@Override
public AssistCreatingConnectionResponse assistCreatingConnection(AssistCreatingConnectionParams params, CancelChecker cancelChecker) {
public AssistCreatingConnectionResponse assistCreatingConnection(AssistCreatingConnectionParams params, SonarLintCancelChecker cancelChecker) {
var tokenValue = params.getTokenValue();
var workspaceFoldersFuture = client.workspaceFolders();
var assistCreatingConnectionFuture = client.assistCreatingConnection(new CreateConnectionParams(false, params.getServerUrl(), tokenValue));
Expand Down Expand Up @@ -284,7 +284,7 @@ private HashMap<String, ServerConnectionSettings> getCurrentConnections(AssistCr
}

@Override
public AssistBindingResponse assistBinding(AssistBindingParams params, CancelChecker cancelChecker) {
public AssistBindingResponse assistBinding(AssistBindingParams params, SonarLintCancelChecker cancelChecker) {
workspaceFoldersManager.updateAnalysisReadiness(Set.of(params.getConfigScopeId()), false);
return client.assistBinding(params)
.thenApply(response -> {
Expand Down Expand Up @@ -402,7 +402,7 @@ public void didReceiveServerHotspotEvent(DidReceiveServerHotspotEvent event) {

@Nullable
@Override
public String matchSonarProjectBranch(String configurationScopeId, String mainBranchName, Set<String> allBranchesNames, CancelChecker cancelChecker) {
public String matchSonarProjectBranch(String configurationScopeId, String mainBranchName, Set<String> allBranchesNames, SonarLintCancelChecker cancelChecker) {
return branchManager.matchSonarProjectBranch(configurationScopeId, mainBranchName, allBranchesNames, cancelChecker);
}

Expand Down Expand Up @@ -546,7 +546,7 @@ private void initializeTaintCache(Set<String> configurationScopeIds) {
}

@Override
public void suggestConnection(Map<String, List<ConnectionSuggestionDto>> configScopesToConnectionSuggestions, CancelChecker cancelChecker) {
public void suggestConnection(Map<String, List<ConnectionSuggestionDto>> configScopesToConnectionSuggestions) {
if (configScopesToConnectionSuggestions.isEmpty()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.jetbrains.annotations.NotNull;
import org.sonarsource.sonarlint.core.client.legacy.analysis.RawIssue;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.hotspot.HotspotStatus;
Expand All @@ -40,6 +39,7 @@
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.ServerMatchedIssueDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.TextRangeWithHashDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.TrackWithServerIssuesParams;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Either;
import org.sonarsource.sonarlint.ls.AnalysisClientInputFile;
import org.sonarsource.sonarlint.ls.backend.BackendServiceFacade;
import org.sonarsource.sonarlint.ls.folders.WorkspaceFoldersManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
import org.sonarsource.sonarlint.core.rpc.client.SonarLintCancelChecker;
import org.sonarsource.sonarlint.ls.backend.BackendServiceFacade;
import org.sonarsource.sonarlint.ls.log.LanguageClientLogOutput;
import org.sonarsource.sonarlint.ls.util.GitUtils;
Expand Down Expand Up @@ -58,7 +58,7 @@ public void shutdown() {
Utils.shutdownAndAwait(executorService, true);
}

public String matchSonarProjectBranch(String folderUri, String mainBranchName, Set<String> allBranchesNames, CancelChecker cancelChecker) {
public String matchSonarProjectBranch(String folderUri, String mainBranchName, Set<String> allBranchesNames, SonarLintCancelChecker cancelChecker) {
if (cancelChecker.isCanceled()) return mainBranchName;
var repo = GitUtils.getRepositoryForDir(Paths.get(URI.create(folderUri)), logOutput);
String electedBranchName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import javax.annotation.concurrent.Immutable;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.common.TransientSonarCloudConnectionDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.common.TransientSonarQubeConnectionDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.validate.ValidateConnectionParams;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Either;
import org.sonarsource.sonarlint.core.rpc.protocol.common.TokenDto;
import org.sonarsource.sonarlint.core.serverapi.EndpointParams;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sonarsource/sonarlint/ls/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.eclipse.lsp4j.jsonrpc.messages.ResponseError;
import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode;
import org.jetbrains.annotations.NotNull;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.common.TransientSonarCloudConnectionDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.common.TransientSonarQubeConnectionDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.validate.ValidateConnectionParams;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.hotspot.HotspotStatus;
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;
import org.sonarsource.sonarlint.ls.IssuesCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -68,6 +67,7 @@
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.TaintVulnerabilityDto;
import org.sonarsource.sonarlint.core.rpc.protocol.common.CleanCodeAttribute;
import org.sonarsource.sonarlint.core.rpc.protocol.common.CleanCodeAttributeCategory;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Either;
import org.sonarsource.sonarlint.core.rpc.protocol.common.ImpactSeverity;
import org.sonarsource.sonarlint.core.rpc.protocol.common.IssueSeverity;
import org.sonarsource.sonarlint.core.rpc.protocol.common.RuleType;
Expand Down Expand Up @@ -562,7 +562,7 @@ void getHtmlDescriptionTabsMonolithicShouldReturnNoTabs() {
var ruleDetails = new EffectiveRuleDetailsDto(null, null, null, null, null, null,
List.of(), Either.forLeft(monolithicDesc), emptyList(), null, null);

assertThat(CommandManager.getHtmlDescriptionTabs(ruleDetails.getDescription(), "")).isEmpty();
assertThat(CommandManager.getHtmlDescriptionTabs(ruleDetails.getDescription().getLsp4jEither(), "")).isEmpty();
}

@Test
Expand All @@ -575,7 +575,7 @@ void getHtmlDescriptionTabsSplitNonContextSections() {
var ruleDetails = new EffectiveRuleDetailsDto(null, null, null, null, null, null,
List.of(), Either.forRight(splitDesc), emptyList(), null, null);

var descriptionTabs = CommandManager.getHtmlDescriptionTabs(ruleDetails.getDescription(), "");
var descriptionTabs = CommandManager.getHtmlDescriptionTabs(ruleDetails.getDescription().getLsp4jEither(), "");

assertThat(descriptionTabs[0].getTitle()).isEqualTo("title1");
assertThat(descriptionTabs[1].getTitle()).isEqualTo("title2");
Expand Down Expand Up @@ -603,7 +603,7 @@ void getHtmlDescriptionTabsSplitContextSection() {
var ruleDetails = new EffectiveRuleDetailsDto(null, null, null, null, null, null,
List.of(), Either.forRight(splitDesc), emptyList(), null, null);

var descriptionTabs = CommandManager.getHtmlDescriptionTabs(ruleDetails.getDescription(), "java");
var descriptionTabs = CommandManager.getHtmlDescriptionTabs(ruleDetails.getDescription().getLsp4jEither(), "java");

assertThat(descriptionTabs[0].getTitle()).isEqualTo("title1");
assertThat(descriptionTabs[1].getTitle()).isEqualTo("title2");
Expand Down Expand Up @@ -631,7 +631,7 @@ void getHtmlDescriptionMonolithic() {
var ruleDetails = new EffectiveRuleDetailsDto(null, null, null, null, null, null,
List.of(), Either.forLeft(monolithicDesc), emptyList(), null, null);

assertThat(CommandManager.getHtmlDescription(ruleDetails.getDescription())).isEqualTo("monolithicHtmlContent");
assertThat(CommandManager.getHtmlDescription(ruleDetails.getDescription().getLsp4jEither())).isEqualTo("monolithicHtmlContent");
}

@Test
Expand All @@ -643,7 +643,7 @@ void getHtmlDescriptionSplit() {
List.of(), Either.forRight(splitDesc), emptyList(), null, null);


assertThat(CommandManager.getHtmlDescription(ruleDetails.getDescription())).isEqualTo("splitHtmlContent");
assertThat(CommandManager.getHtmlDescription(ruleDetails.getDescription().getLsp4jEither())).isEqualTo("splitHtmlContent");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.eclipse.lsp4j.MessageActionItem;
import org.eclipse.lsp4j.MessageParams;
import org.eclipse.lsp4j.MessageType;
import org.eclipse.lsp4j.ShowMessageRequestParams;
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -160,8 +158,6 @@ class SonarLintVSCodeClientTests {
TaintVulnerabilitiesCache taintVulnerabilitiesCache = mock(TaintVulnerabilitiesCache.class);
AnalysisScheduler analysisScheduler = mock(AnalysisScheduler.class);
DiagnosticPublisher diagnosticPublisher = mock(DiagnosticPublisher.class);
private static final CancelChecker NOP_CANCEL_TOKEN = () -> {
};

private static final String PEM = """
subject=CN=localhost,O=SonarSource SA,L=Geneva,ST=Geneva,C=CH
Expand Down Expand Up @@ -290,7 +286,7 @@ void shouldSuggestConnection() {
var suggestions = new HashMap<String, List<ConnectionSuggestionDto>>();
suggestions.put("key", List.of());

underTest.suggestConnection(suggestions, NOP_CANCEL_TOKEN);
underTest.suggestConnection(suggestions);

var captor = ArgumentCaptor.forClass(SuggestConnectionParams.class);
verify(client).suggestConnection(captor.capture());
Expand All @@ -299,7 +295,7 @@ void shouldSuggestConnection() {

@Test
void shouldSkipEmptySuggestionConnection() {
underTest.suggestConnection(Map.of(), NOP_CANCEL_TOKEN);
underTest.suggestConnection(Map.of());

verify(client, never()).suggestBinding(any());
}
Expand Down Expand Up @@ -392,7 +388,7 @@ void shouldCallServerOnGetHostInfo() {
}

@Test
void shouldGetHostInfo() throws ExecutionException, InterruptedException {
void shouldGetHostInfo() {
var desc = "This is Test";
when(server.getHostInfo()).thenReturn(new GetClientLiveInfoResponse("This is Test"));
var result = underTest.getClientLiveDescription();
Expand Down Expand Up @@ -495,7 +491,7 @@ void testNoBindingSuggestionFound() {
}

@Test
void checkServerTrusted() throws ExecutionException, InterruptedException {
void checkServerTrusted() {
var params = new CheckServerTrustedParams(List.of(new X509CertificateDto(PEM)), "authType");
when(client.askSslCertificateConfirmation(any())).thenReturn(CompletableFuture.completedFuture(true));

Expand Down Expand Up @@ -528,7 +524,7 @@ void testShowSoonUnsupportedVersion() {
}

@Test
void checkServerTrustedMalformedCert() throws ExecutionException, InterruptedException {
void checkServerTrustedMalformedCert() {
var params = new CheckServerTrustedParams(List.of(new X509CertificateDto("malformed")), "authType");
when(client.askSslCertificateConfirmation(any())).thenReturn(CompletableFuture.completedFuture(true));

Expand Down Expand Up @@ -697,7 +693,7 @@ void shouldPopulateTaintsCacheOnAnalysisReadinessChangedAndPublishDiagnostics()
}

@Test
void testDefaultProxyBehavior() throws ExecutionException, InterruptedException, URISyntaxException {
void testDefaultProxyBehavior() throws URISyntaxException {
ProxySelector.setDefault(new ProxySelector() {
@Override
public List<Proxy> select(URI uri) {
Expand Down Expand Up @@ -728,7 +724,7 @@ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
}

@Test
void testDefaultAuthenticatorBehavior() throws ExecutionException, InterruptedException, MalformedURLException {
void testDefaultAuthenticatorBehavior() throws MalformedURLException {

Authenticator.setDefault(new Authenticator() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;
import org.sonarsource.sonarlint.core.client.legacy.analysis.RawIssue;
import org.sonarsource.sonarlint.core.client.legacy.analysis.SonarLintAnalysisEngine;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.LocalOnlyIssueDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.ServerMatchedIssueDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.TrackWithServerIssuesResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Either;
import org.sonarsource.sonarlint.core.rpc.protocol.common.IssueSeverity;
import org.sonarsource.sonarlint.core.rpc.protocol.common.RuleType;
import org.sonarsource.sonarlint.ls.AnalysisClientInputFile;
Expand All @@ -60,8 +59,6 @@

class ServerIssueTrackerWrapperTests {

@TempDir
Path baseDir;
@RegisterExtension
SonarLintLogTester logTester = new SonarLintLogTester();

Expand Down

0 comments on commit 10fd1ba

Please sign in to comment.