From 5846ac494a739cc40cee17eb1c1fafbdb5ca5242 Mon Sep 17 00:00:00 2001 From: Nicolas QUINQUENEL Date: Thu, 3 Oct 2024 10:24:21 +0200 Subject: [PATCH] Improvements --- .../sonarlint/intellij/rider/RiderFilesContributor.kt | 6 ------ .../org/sonarlint/intellij/SonarLintIntelliJClient.kt | 8 +++++++- .../intellij/mediumtests/StandaloneModeMediumTests.kt | 9 ++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/rider/src/main/java/org/sonarlint/intellij/rider/RiderFilesContributor.kt b/rider/src/main/java/org/sonarlint/intellij/rider/RiderFilesContributor.kt index fa4716aa6..01fbe1144 100644 --- a/rider/src/main/java/org/sonarlint/intellij/rider/RiderFilesContributor.kt +++ b/rider/src/main/java/org/sonarlint/intellij/rider/RiderFilesContributor.kt @@ -20,7 +20,6 @@ package org.sonarlint.intellij.rider import com.intellij.openapi.module.Module -import com.intellij.openapi.project.guessProjectDir import com.intellij.openapi.vfs.VirtualFile import com.jetbrains.rider.projectView.workspace.ProjectModelEntity import com.jetbrains.rider.projectView.workspace.ProjectModelEntityVisitor @@ -37,11 +36,6 @@ class RiderFilesContributor : FilesContributor { // List files in Solution filesInContentRoots.addAll(listFilesInSolution(module)) - // List files in project dir, sometimes not all files are found via the previous method - filesInContentRoots.addAll( - module.project.guessProjectDir()?.children?.filter { !it.isDirectory && it.isValid }?.toSet() ?: emptySet() - ) - return filesInContentRoots } diff --git a/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt b/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt index f0118ee4f..dd36e44ad 100644 --- a/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt +++ b/src/main/java/org/sonarlint/intellij/SonarLintIntelliJClient.kt @@ -69,6 +69,7 @@ import org.sonarlint.intellij.analysis.RunningAnalysesTracker import org.sonarlint.intellij.common.analysis.FilesContributor import org.sonarlint.intellij.common.ui.ReadActionUtils.Companion.computeReadActionSafely import org.sonarlint.intellij.common.ui.SonarLintConsole +import org.sonarlint.intellij.common.util.FileUtils.Companion.isFileValidForSonarLintWithExtensiveChecks import org.sonarlint.intellij.common.util.SonarLintUtils.getService import org.sonarlint.intellij.common.util.SonarLintUtils.isRider import org.sonarlint.intellij.common.vcs.VcsRepo @@ -796,7 +797,12 @@ object SonarLintIntelliJClient : SonarLintRpcClientDelegate { // useful for Rider where the files to find are not located in content roots private fun listFilesInProjectBaseDir(project: Project): Set { - return project.guessProjectDir()?.children?.filter { !it.isDirectory && it.isValid }?.toSet() ?: return emptySet() + return project.guessProjectDir()?.children?.filter { + !it.isDirectory && it.isValid && isFileValidForSonarLintWithExtensiveChecks( + it, + project + ) + }?.toSet() ?: return emptySet() } override fun didChangeTaintVulnerabilities( diff --git a/src/test/java/org/sonarlint/intellij/mediumtests/StandaloneModeMediumTests.kt b/src/test/java/org/sonarlint/intellij/mediumtests/StandaloneModeMediumTests.kt index 04c19d733..a92fabd7d 100644 --- a/src/test/java/org/sonarlint/intellij/mediumtests/StandaloneModeMediumTests.kt +++ b/src/test/java/org/sonarlint/intellij/mediumtests/StandaloneModeMediumTests.kt @@ -53,13 +53,12 @@ import org.sonarlint.intellij.core.BackendService import org.sonarlint.intellij.finding.issue.LiveIssue import org.sonarlint.intellij.fs.VirtualFileEvent import org.sonarlint.intellij.trigger.TriggerType -import org.sonarlint.intellij.util.ProjectUtils +import org.sonarlint.intellij.util.SonarLintAppUtils import org.sonarlint.intellij.util.getDocument import org.sonarsource.sonarlint.core.rpc.protocol.common.IssueSeverity import org.sonarsource.sonarlint.core.rpc.protocol.common.RuleType import org.sonarsource.sonarlint.plugin.api.module.file.ModuleFileEvent -@Disabled("Symbolic link check from SLCORE does not work with temp files") class StandaloneModeMediumTests : AbstractSonarLintLightTests() { private val diamondQuickFix = "SonarLint: Replace with <>" @@ -144,7 +143,7 @@ class StandaloneModeMediumTests : AbstractSonarLintLightTests() { } @Test - @Disabled("Error: ENOENT: no such file or directory, scandir '/src'") + @Disabled("Provider \"temp\" not installed") fun should_analyze_js_in_yaml_file() { val fileToAnalyze = sendFileToBackend("src/lambda.yaml") @@ -313,7 +312,7 @@ class StandaloneModeMediumTests : AbstractSonarLintLightTests() { } @Test - @Disabled("Ignored file still analyzed") + @Disabled("Provider \"temp\" not installed") fun should_find_secrets_excluding_vcs_ignored_files() { sendFileToBackend("src/devenv.js") val fileToAnalyzeIgnored = sendFileToBackend("src/devenv_ignored.js") @@ -492,7 +491,7 @@ class StandaloneModeMediumTests : AbstractSonarLintLightTests() { } val onTheFlyFindingsHolder = getService(project, AnalysisSubmitter::class.java).onTheFlyFindingsHolder - val issues = ProjectUtils.getAllFiles(project).toList().map { + val issues = SonarLintAppUtils.visitAndAddAllFilesForProject(project).toList().map { onTheFlyFindingsHolder.getIssuesForFile(it) }.toList().flatten() return issues