aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-10-24 10:54:15 +0200
committersonartech <sonartech@sonarsource.com>2024-10-24 20:02:44 +0000
commite0a940902f37156757e84544d0a876f47f69040f (patch)
tree988c74e5242ad1bb349148601bb207b7cf515b09 /sonar-core
parentc11922595bf67a70a38588a6f7763fb6f6c14501 (diff)
downloadsonarqube-e0a940902f37156757e84544d0a876f47f69040f.tar.gz
sonarqube-e0a940902f37156757e84544d0a876f47f69040f.zip
SONAR-23427 Stop relying on Qualifiers, Scopes and ResourceType from the plugin API
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java71
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java12
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java6
-rw-r--r--sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java36
7 files changed, 29 insertions, 136 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java b/sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java
deleted file mode 100644
index bcc1d1d4a15..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-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 GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * 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 GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import org.sonar.api.ce.ComputeEngineSide;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.ResourceType;
-import org.sonar.api.resources.ResourceTypeTree;
-import org.sonar.api.scanner.ScannerSide;
-import org.sonar.api.server.ServerSide;
-
-@ScannerSide
-@ServerSide
-@ComputeEngineSide
-public final class DefaultResourceTypes {
-
- private static final String CONFIGURABLE = "configurable";
- private static final String UPDATABLE_KEY = "updatable_key";
- public static final String IGNORED = "ignored";
-
- private DefaultResourceTypes() {
- // only static methods
- }
-
- public static ResourceTypeTree get() {
- return ResourceTypeTree.builder()
- .addType(ResourceType.builder(Qualifiers.PROJECT)
- .setProperty("deletable", true)
- .setProperty("modifiable_history", true)
- .setProperty("hasRolePolicy", true)
- .setProperty(UPDATABLE_KEY, true)
- .setProperty("comparable", true)
- .setProperty(CONFIGURABLE, true)
- .build())
- .addType(ResourceType.builder(Qualifiers.MODULE)
- .setProperty(UPDATABLE_KEY, true)
- .setProperty(CONFIGURABLE, true)
- .setProperty(IGNORED, true)
- .build())
- .addType(ResourceType.builder(Qualifiers.DIRECTORY)
- .build())
- .addType(ResourceType.builder(Qualifiers.FILE)
- .hasSourceCode()
- .build())
- .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE)
- .hasSourceCode()
- .build())
-
- .addRelations(Qualifiers.PROJECT, Qualifiers.DIRECTORY)
- .addRelations(Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE)
-
- .build();
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
index 538964a8117..440c6d09ff4 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
@@ -26,7 +26,7 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.PropertyType;
import org.sonar.api.config.EmailSettings;
import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.config.PropertyDefinition.ConfigScope;
import org.sonar.core.documentation.DefaultDocumentationLinkGenerator;
import org.sonar.core.extension.PluginRiskConsent;
@@ -78,7 +78,7 @@ public class CorePropertyDefinitions {
"necessary changes, clear this setting to prevent analysis from showing a warning about it.")
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_MODULES)
- .onlyOnQualifiers(Qualifiers.PROJECT)
+ .onlyOnConfigScopes(ConfigScope.PROJECT)
.type(TEXT)
.build(),
PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL)
@@ -179,7 +179,7 @@ public class CorePropertyDefinitions {
.description("Don't show issue facets aggregating information per developer")
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_ISSUES)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.type(BOOLEAN)
.defaultValue(Boolean.toString(false))
.build(),
@@ -189,7 +189,7 @@ public class CorePropertyDefinitions {
.description("New issues will be assigned to this user each time it is not possible to determine the user who is the author of the issue.")
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_ISSUES)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.type(PropertyType.USER_LOGIN)
.build(),
@@ -199,7 +199,7 @@ public class CorePropertyDefinitions {
.description("Quality Gate conditions about duplications in new code and coverage on new code are ignored until the number of new lines is at least 20.")
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_QUALITY_GATE)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.type(BOOLEAN)
.defaultValue(Boolean.toString(true))
.build(),
@@ -214,7 +214,7 @@ public class CorePropertyDefinitions {
+ "this property will significantly increase each SonarQube analysis time, "
+ "and therefore badly impact the performances of report processing as more and more projects "
+ "are getting involved in this cross project duplication mechanism.")
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_DUPLICATIONS)
.type(BOOLEAN)
@@ -224,7 +224,7 @@ public class CorePropertyDefinitions {
.name("Duplication Exclusions")
.description("Patterns used to exclude some source files from the duplication detection mechanism. " +
"See below to know how to use wildcards to specify this property.")
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_EXCLUSIONS)
.subCategory(CoreProperties.SUBCATEGORY_DUPLICATIONS_EXCLUSIONS)
.multiValues(true)
diff --git a/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java b/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java
index 0f384a4accf..248d64e4f6a 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/ExclusionProperties.java
@@ -23,7 +23,7 @@ import java.util.List;
import org.sonar.api.CoreProperties;
import org.sonar.api.PropertyType;
import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.config.PropertyDefinition.ConfigScope;
public class ExclusionProperties {
@@ -40,7 +40,7 @@ public class ExclusionProperties {
.subCategory(CoreProperties.SUBCATEGORY_COVERAGE_EXCLUSIONS)
.type(PropertyType.STRING)
.multiValues(true)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.build(),
// FILES
@@ -64,7 +64,7 @@ public class ExclusionProperties {
.multiValues(true)
.category(CoreProperties.CATEGORY_EXCLUSIONS)
.subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(0)
.build(),
@@ -73,7 +73,7 @@ public class ExclusionProperties {
.multiValues(true)
.category(CoreProperties.CATEGORY_EXCLUSIONS)
.subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(1)
.build(),
PropertyDefinition.builder(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY)
@@ -81,7 +81,7 @@ public class ExclusionProperties {
.multiValues(true)
.category(CoreProperties.CATEGORY_EXCLUSIONS)
.subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(2)
.build(),
PropertyDefinition.builder(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY)
@@ -89,7 +89,7 @@ public class ExclusionProperties {
.multiValues(true)
.category(CoreProperties.CATEGORY_EXCLUSIONS)
.subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(3)
.build()
diff --git a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java
index cf2db944d51..c77ea4fbf3e 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java
@@ -23,8 +23,8 @@ import java.util.List;
import org.sonar.api.CoreProperties;
import org.sonar.api.PropertyType;
import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.config.PropertyDefinition.ConfigScope;
import org.sonar.api.config.PropertyFieldDefinition;
-import org.sonar.api.resources.Qualifiers;
public final class IssueExclusionProperties {
@@ -64,7 +64,7 @@ public final class IssueExclusionProperties {
.subCategory(SUB_CATEGORY_IGNORE_ISSUES)
.name("Ignore Issues on Multiple Criteria")
.description("Patterns to ignore issues on certain components and for certain coding rules." + PROPERTY_RULE_KEY_PATTERN_HELP)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(3)
.fields(
PropertyFieldDefinition.build(RULE_KEY)
@@ -85,7 +85,7 @@ public final class IssueExclusionProperties {
.name("Ignore Issues in Blocks")
.description("Patterns to ignore all issues on specific blocks of code, " +
"while continuing to scan and mark issues on the remainder of the file.")
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(2)
.fields(
PropertyFieldDefinition.build(BEGIN_BLOCK_REGEXP)
@@ -105,7 +105,7 @@ public final class IssueExclusionProperties {
.subCategory(SUB_CATEGORY_IGNORE_ISSUES)
.name("Ignore Issues on Files")
.description("Patterns to ignore all issues on files that contain a block of code matching a given regular expression.")
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(1)
.fields(
PropertyFieldDefinition.build(FILE_REGEXP)
@@ -120,7 +120,7 @@ public final class IssueExclusionProperties {
.subCategory(SUB_CATEGORY_IGNORE_ISSUES)
.name("Restrict Scope of Coding Rules")
.description("Patterns to restrict the application of a rule to only certain components, ignoring all others." + PROPERTY_RULE_KEY_PATTERN_HELP)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.index(4)
.fields(
PropertyFieldDefinition.build(RULE_KEY)
diff --git a/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java b/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java
index c1068e385c1..255f8fbbc8f 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java
@@ -23,7 +23,7 @@ import java.util.List;
import org.sonar.api.CoreProperties;
import org.sonar.api.PropertyType;
import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.config.PropertyDefinition.ConfigScope;
import static java.util.Arrays.asList;
import static org.sonar.core.config.Frequency.MONTHLY;
@@ -42,7 +42,7 @@ public final class PurgeProperties {
.description("After this number of hours, if there are several analyses during the same day, "
+ "the DbCleaner keeps the most recent one and fully deletes the other ones.")
.type(PropertyType.INTEGER)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_HOUSEKEEPING)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.index(1)
@@ -54,7 +54,7 @@ public final class PurgeProperties {
.description("After this number of weeks, if there are several analyses during the same week, "
+ "the DbCleaner keeps the most recent one and fully deletes the other ones")
.type(PropertyType.INTEGER)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_HOUSEKEEPING)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.index(2)
@@ -66,7 +66,7 @@ public final class PurgeProperties {
.description("After this number of weeks, if there are several analyses during the same month, "
+ "the DbCleaner keeps the most recent one and fully deletes the other ones.")
.type(PropertyType.INTEGER)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_HOUSEKEEPING)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.index(3)
@@ -77,7 +77,7 @@ public final class PurgeProperties {
.name("Keep only analyses with a version event after")
.description("After this number of weeks, the DbCleaner keeps only analyses with a version event associated.")
.type(PropertyType.INTEGER)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_HOUSEKEEPING)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.index(4)
@@ -88,7 +88,7 @@ public final class PurgeProperties {
.name("Delete all analyses after")
.description("After this number of weeks, all analyses are fully deleted.")
.type(PropertyType.INTEGER)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_HOUSEKEEPING)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.index(5)
@@ -99,7 +99,7 @@ public final class PurgeProperties {
.name("Delete closed issues after")
.description("Issues that have been closed for more than this number of days will be deleted.")
.type(PropertyType.INTEGER)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_HOUSEKEEPING)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.index(6)
@@ -110,7 +110,7 @@ public final class PurgeProperties {
.name("Delete anticipated transitions after")
.description("Anticipated transitions that have not been applied for more than this number of days will be deleted.")
.type(PropertyType.INTEGER)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.category(CoreProperties.CATEGORY_HOUSEKEEPING)
.subCategory(CoreProperties.SUBCATEGORY_GENERAL)
.index(7)
diff --git a/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java b/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java
index f919a44db58..e024b91cfca 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/ScannerProperties.java
@@ -22,7 +22,7 @@ package org.sonar.core.config;
import java.util.List;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.config.PropertyDefinition.ConfigScope;
import static java.util.Arrays.asList;
import static org.sonar.api.PropertyType.BOOLEAN;
@@ -53,14 +53,14 @@ public class ScannerProperties {
.description("Disable the retrieval of blame information from Source Control Manager")
.category(CoreProperties.CATEGORY_SCM)
.type(BOOLEAN)
- .onQualifiers(Qualifiers.PROJECT)
+ .onConfigScopes(ConfigScope.PROJECT)
.defaultValue(String.valueOf(false))
.build(),
PropertyDefinition.builder(CoreProperties.SCM_PROVIDER_KEY)
.name("Key of the SCM provider for this project")
.description("Force the provider to be used to get SCM information for this project. By default auto-detection is done. Example: svn, git.")
.category(CoreProperties.CATEGORY_SCM)
- .onlyOnQualifiers(Qualifiers.PROJECT)
+ .onlyOnConfigScopes(ConfigScope.PROJECT)
.build(),
PropertyDefinition.builder(BRANCH_NAME)
.name("Optional name of SonarQube/SCM branch")
diff --git a/sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java b/sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java
deleted file mode 100644
index cfa542513ee..00000000000
--- a/sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-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 GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * 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 GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import org.junit.Test;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.ResourceTypeTree;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultResourceTypesTest {
- @Test
- public void provide_types() {
- ResourceTypeTree tree = DefaultResourceTypes.get();
-
- assertThat(tree.getTypes()).hasSize(5);
- assertThat(tree.getChildren(Qualifiers.PROJECT)).containsExactly(Qualifiers.DIRECTORY);
- }
-}