From dc0ec06cc1b44f91f493ab427081083734422916 Mon Sep 17 00:00:00 2001 From: Nicolas QUINQUENEL Date: Fri, 27 Sep 2024 17:04:20 +0200 Subject: [PATCH 1/2] SLI-1629 Improve how Node.js is loaded --- gradle/libs.versions.toml | 2 +- .../global/SonarLintGlobalOptionsPanel.java | 38 +++++++++++++------ .../sonarlint/intellij/core/BackendService.kt | 8 ++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 304a30dac..c290ed37d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -sonarlint-core = "10.6.0.79033" +sonarlint-core = "10.7.0.79079" sonar-java = "8.4.0.37032" sonar-javascript = "10.16.0.27621" diff --git a/src/main/java/org/sonarlint/intellij/config/global/SonarLintGlobalOptionsPanel.java b/src/main/java/org/sonarlint/intellij/config/global/SonarLintGlobalOptionsPanel.java index 4209e8480..9afac99c4 100644 --- a/src/main/java/org/sonarlint/intellij/config/global/SonarLintGlobalOptionsPanel.java +++ b/src/main/java/org/sonarlint/intellij/config/global/SonarLintGlobalOptionsPanel.java @@ -33,6 +33,7 @@ import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.nio.file.Paths; import java.util.Objects; import javax.swing.BorderFactory; import javax.swing.JComponent; @@ -51,7 +52,8 @@ public class SonarLintGlobalOptionsPanel implements ConfigurationPanel { private static final String NODE_JS_TOOLTIP = "SonarLint requires Node.js to analyze some languages. You can provide an explicit path for the node executable here or leave " + - "this field blank to let SonarLint look for it using your PATH environment variable."; + "this field blank to let SonarLint look for it using your PATH environment variable." + + " Restarting your IDE is recommended."; private JPanel rootPane; private JBCheckBox autoTrigger; private JBTextField nodeJsPath; @@ -136,19 +138,31 @@ public void load(SonarLintGlobalSettings model) { autoTrigger.setSelected(model.isAutoTrigger()); nodeJsPath.setText(model.getNodejsPath()); focusOnNewCode.setSelected(model.isFocusOnNewCode()); - loadNodeJsSettings(); + loadNodeJsSettings(model); } - private void loadNodeJsSettings() { - getService(BackendService.class).getAutoDetectedNodeJs().thenAccept(settings -> { - if (settings == null) { - this.nodeJsPath.getEmptyText().setText("Node.js not found"); - this.nodeJsVersion.setText("N/A"); - } else { - this.nodeJsPath.getEmptyText().setText(settings.getPath().toString()); - this.nodeJsVersion.setText(settings.getVersion()); - } - }); + private void loadNodeJsSettings(SonarLintGlobalSettings model) { + if (model.getNodejsPath() == null || model.getNodejsPath().isBlank()) { + getService(BackendService.class).getAutoDetectedNodeJs().thenAccept(settings -> { + if (settings == null) { + this.nodeJsPath.getEmptyText().setText("Node.js not found"); + this.nodeJsVersion.setText("N/A"); + } else { + this.nodeJsPath.getEmptyText().setText(settings.getPath().toString()); + this.nodeJsVersion.setText(settings.getVersion()); + } + }); + } else { + var forcedNodeJsPath = Paths.get(model.getNodejsPath()); + getService(BackendService.class).changeClientNodeJsPath(forcedNodeJsPath).thenAccept(settings -> { + if (settings == null) { + this.nodeJsVersion.setText("N/A"); + } else { + this.nodeJsPath.setText(settings.getPath().toString()); + this.nodeJsVersion.setText(settings.getVersion()); + } + }); + } } @Override diff --git a/src/main/java/org/sonarlint/intellij/core/BackendService.kt b/src/main/java/org/sonarlint/intellij/core/BackendService.kt index b88c4753c..37e256c28 100644 --- a/src/main/java/org/sonarlint/intellij/core/BackendService.kt +++ b/src/main/java/org/sonarlint/intellij/core/BackendService.kt @@ -89,6 +89,7 @@ import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcServer import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.AnalyzeFilesAndTrackParams import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.AnalyzeFilesResponse import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.DidChangeAutomaticAnalysisSettingParams +import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.DidChangeClientNodeJsPathParams import org.sonarsource.sonarlint.core.rpc.protocol.backend.binding.GetSharedConnectedModeConfigFileParams import org.sonarsource.sonarlint.core.rpc.protocol.backend.binding.GetSharedConnectedModeConfigFileResponse import org.sonarsource.sonarlint.core.rpc.protocol.backend.branch.DidVcsRepositoryChangeParams @@ -894,6 +895,13 @@ class BackendService : Disposable { } } + fun changeClientNodeJsPath(nodeJsPath: Path?): CompletableFuture { + return requestFromBackend { it.analysisService.didChangeClientNodeJsPath(DidChangeClientNodeJsPathParams(nodeJsPath)) } + .thenApplyAsync { response -> + response.details?.let { NodeJsSettings(it.path, it.version) } + } + } + fun updateFileSystem(filesByModule: Map>) { val deletedFileUris = filesByModule.values .flatMap { it.filter { event -> event.type == ModuleFileEvent.Type.DELETED } } From 3cba3eb16987c34ea75cf0ab2be0cec3dccb55cd Mon Sep 17 00:00:00 2001 From: Nicolas QUINQUENEL Date: Wed, 2 Oct 2024 17:02:00 +0200 Subject: [PATCH 2/2] Update change notes and use latest version of SLCORE --- gradle/libs.versions.toml | 2 +- .../java/org/sonarlint/intellij/SonarLintIntelliJClient.kt | 6 +++--- .../sonarlint/intellij/trigger/SonarLintCheckinHandler.java | 4 +++- src/main/resources/META-INF/plugin.xml | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c290ed37d..ca8f86161 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -sonarlint-core = "10.7.0.79079" +sonarlint-core = "10.7.0.79122" sonar-java = "8.4.0.37032" sonar-javascript = "10.16.0.27621" diff --git a/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt b/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt index 411118cd4..1e27a3675 100644 --- a/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt +++ b/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt @@ -852,7 +852,7 @@ object SonarLintIntelliJClient : SonarLintRpcClientDelegate { override fun raiseHotspots( configurationScopeId: String, - issuesByFileUri: Map>, + hotspotsByFileUri: Map>, isIntermediatePublication: Boolean, analysisId: UUID?, ) { @@ -861,13 +861,13 @@ object SonarLintIntelliJClient : SonarLintRpcClientDelegate { val runningAnalysis = analysisId?.let { getService(project, RunningAnalysesTracker::class.java).getById(it) } if (runningAnalysis != null) { - runningAnalysis.addRawHotspots(analysisId, issuesByFileUri, isIntermediatePublication) + runningAnalysis.addRawHotspots(analysisId, hotspotsByFileUri, isIntermediatePublication) if (runningAnalysis.isAnalysisFinished()) { getService(project, RunningAnalysesTracker::class.java).finish(runningAnalysis) } } else if (analysisId == null && module != null) { val onTheFlyFindingsHolder = getService(project, AnalysisSubmitter::class.java).onTheFlyFindingsHolder - onTheFlyFindingsHolder.updateViewsWithNewSecurityHotspots(module, issuesByFileUri) + onTheFlyFindingsHolder.updateViewsWithNewSecurityHotspots(module, hotspotsByFileUri) } } diff --git a/src/main/java/org/sonarlint/intellij/trigger/SonarLintCheckinHandler.java b/src/main/java/org/sonarlint/intellij/trigger/SonarLintCheckinHandler.java index 2050c477d..96eaca4d6 100644 --- a/src/main/java/org/sonarlint/intellij/trigger/SonarLintCheckinHandler.java +++ b/src/main/java/org/sonarlint/intellij/trigger/SonarLintCheckinHandler.java @@ -60,6 +60,7 @@ import org.sonarlint.intellij.finding.LiveFindings; import org.sonarlint.intellij.finding.hotspot.LiveSecurityHotspot; import org.sonarlint.intellij.finding.issue.LiveIssue; +import org.sonarsource.sonarlint.core.client.utils.ImpactSeverity; import org.sonarsource.sonarlint.core.commons.IssueSeverity; import org.sonarsource.sonarlint.core.commons.api.SonarLanguage; @@ -161,7 +162,8 @@ private ReturnResult processResults(List results) { .flatMap(e -> e.getValue().stream()) .filter(Predicate.not(LiveIssue::isResolved)) .filter(issue -> !shouldFocusOnNewCode || issue.isOnNewCode()) - .filter(i -> i.getUserSeverity() != null && i.getUserSeverity().name().equals(IssueSeverity.BLOCKER.name())) + .filter(i -> (i.getHighestImpact() != null && i.getHighestImpact().name().equals(ImpactSeverity.BLOCKER.name())) + || (i.getUserSeverity() != null && i.getUserSeverity().name().equals(IssueSeverity.BLOCKER.name()))) .count(); if (numIssues == 0) { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 7f0861573..54d4fa37d 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -64,7 +64,7 @@ -
  • 10.11 - 1 new PHP rule. 7 new Python rules related to PyTorch. Bug fixes, fewer FPs and improvements for many languages.
  • +
  • 10.11 - Optimize the triggering of analysis and automatically cancel redundant ones. Avoid an error related to the .gitignore file. Fix an issue where a custom Node.js path would not be considered. Optimize SonarLint initialization performance and reduce the file system cache usage. Improve error feedback with Connected Mode. 1 new PHP rule. 7 new Python rules related to PyTorch. Bug fixes, fewer FPs and improvements for many languages.
  • 10.10 - Improve SonarLint performance and optimize memory usage. Refactor thread management to avoid UI freezes. Avoid errors of type 'No file to analyze'. Support detection of Micronaut configuration issues. 6 new JS/TS rules. Introduce new INFO and BLOCKER severities. Improve UI feedback when lacking permission with SonarQube or SonarCloud. Bug fixes, fewer FPs and improvements for many languages.
  • 10.9 - Support analysis of Helm files. Improve analysis consistency on Rider. 7 new C++23 rules and C++23 support. Bug fixes, fewer FPs and improvements for many languages.
  • 10.8.1 - Correctly display the current file analysis results on dev containers. Fix an issue where triggering a report analysis would disappear. Fix a problem where issues from another project would appear in the report.