From e2fa6ffdab029a38c26d30cd3fcaacdde843fb54 Mon Sep 17 00:00:00 2001 From: Sophio Japharidze Date: Wed, 29 May 2024 11:07:43 +0200 Subject: [PATCH] SLCORE-672 remove explicit dependency check for DBD plugins --- .../loading/SonarPluginRequirementsChecker.java | 10 +--------- .../SonarPluginRequirementsCheckerTests.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/backend/plugin-commons/src/main/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsChecker.java b/backend/plugin-commons/src/main/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsChecker.java index a951349aef..2517392817 100644 --- a/backend/plugin-commons/src/main/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsChecker.java +++ b/backend/plugin-commons/src/main/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsChecker.java @@ -173,17 +173,9 @@ private static PluginRequirementsCheckResult checkUnsatisfiedPluginDependency(Pl if (basePluginKey != null && checkForPluginSkipped(currentResultsByKey.get(basePluginKey))) { return processUnsatisfiedDependency(currentResult.getPlugin(), basePluginKey); } - if (DataflowBugDetection.PLUGIN_ALLOW_LIST.contains(plugin.getKey())) { - // Workaround for SLCORE-667 - // dbd and dbdpythonfrontend require Python to be working - if (!enableDataflowBugDetection) { + if (DataflowBugDetection.PLUGIN_ALLOW_LIST.contains(plugin.getKey()) && !enableDataflowBugDetection) { LOG.debug("DBD feature disabled. Skip loading plugin '{}'.", plugin.getName()); return new PluginRequirementsCheckResult(plugin, SkipReason.UnsupportedFeature.INSTANCE); - } - var pythonPluginResult = currentResultsByKey.get(SonarLanguage.PYTHON.getPluginKey()); - if (checkForPluginSkipped(pythonPluginResult)) { - return processUnsatisfiedDependency(currentResult.getPlugin(), SonarLanguage.PYTHON.getPluginKey()); - } } return currentResult; } diff --git a/backend/plugin-commons/src/test/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsCheckerTests.java b/backend/plugin-commons/src/test/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsCheckerTests.java index 0b28864992..bbcefe4c46 100644 --- a/backend/plugin-commons/src/test/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsCheckerTests.java +++ b/backend/plugin-commons/src/test/java/org/sonarsource/sonarlint/core/plugin/commons/loading/SonarPluginRequirementsCheckerTests.java @@ -390,10 +390,11 @@ void load_plugin_skip_plugins_having_unsatisfied_python_frontend_dbd(@TempDir Pa assertThat(logsWithoutStartStop()).contains("DBD feature disabled. Skip loading plugin 'dbdpythonfrontend'."); } + @Test void load_plugin_skip_plugins_having_unsatisfied_python_dbd(@TempDir Path storage) throws IOException { var fakePlugin = fakePlugin(storage, "fake.jar", - path -> createPluginManifest(path, "dbd", V1_0)); + path -> createPluginManifest(path, "dbd", V1_0, withRequiredPlugins("python:1.15"))); Set jars = Set.of(fakePlugin); var loadedPlugins = underTest.checkRequirements(jars, NONE, null, Optional.empty(), true); @@ -403,6 +404,18 @@ void load_plugin_skip_plugins_having_unsatisfied_python_dbd(@TempDir Path storag assertThat(logsWithoutStartStop()).contains("Plugin 'dbd' dependency on 'python' is unsatisfied. Skip loading it."); } + @Test + void load_plugin_skip_plugins_having_unsatisfied_java_dbd(@TempDir Path storage) throws IOException { + var fakePlugin = fakePlugin(storage, "fake.jar", + path -> createPluginManifest(path, "dbd", V1_0, withRequiredPlugins("java:7.35"))); + Set jars = Set.of(fakePlugin); + + var loadedPlugins = underTest.checkRequirements(jars, NONE, null, Optional.empty(), true); + + assertThat(loadedPlugins.values()).extracting(r -> r.getPlugin().getKey(), PluginRequirementsCheckResult::isSkipped, p -> p.getSkipReason().orElse(null)) + .containsOnly(tuple("dbd", true, new SkipReason.UnsatisfiedDependency(SonarLanguage.JAVA.getPluginKey()))); + assertThat(logsWithoutStartStop()).contains("Plugin 'dbd' dependency on 'java' is unsatisfied. Skip loading it."); + } @Test void load_plugin_having_satisfied_python_frontend_dbd(@TempDir Path storage) throws IOException { var fakePlugin = fakePlugin(storage, "fake.jar",