aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorDejan Milisavljevic <dejan.milisavljevic@sonarsource.com>2024-08-08 15:27:05 +0200
committersonartech <sonartech@sonarsource.com>2024-08-26 20:03:05 +0000
commita396c6dcefeaf6aca14ba957197f7e45e91ecb5b (patch)
treed9e0a54edeb4b4eb70ccf4a5991dd7d73f4f2b16 /sonar-core
parent855725871155f9524b37cc1e32cff0b25c77dab3 (diff)
downloadsonarqube-a396c6dcefeaf6aca14ba957197f7e45e91ecb5b.tar.gz
sonarqube-a396c6dcefeaf6aca14ba957197f7e45e91ecb5b.zip
SONAR-22731 Define flag to be able to use legacy ratings
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java1
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/LegacyRatingConstants.java31
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/LegacyRatingProperties.java55
-rw-r--r--sonar-core/src/test/java/org/sonar/core/config/LegacyRatingPropertiesTest.java31
4 files changed, 118 insertions, 0 deletions
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 758efac19cd..86f2f2ea797 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
@@ -68,6 +68,7 @@ public class CorePropertyDefinitions {
defs.addAll(PurgeProperties.all());
defs.addAll(EmailSettings.definitions());
defs.addAll(ScannerProperties.all());
+ defs.addAll(LegacyRatingProperties.all());
defs.addAll(asList(
PropertyDefinition.builder(CoreProperties.MODULE_LEVEL_ARCHIVED_SETTINGS)
diff --git a/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingConstants.java b/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingConstants.java
new file mode 100644
index 00000000000..847de4cd930
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingConstants.java
@@ -0,0 +1,31 @@
+/*
+ * 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.config;
+
+public class LegacyRatingConstants {
+
+ public static final String LEGACY_RATING_CATEGORY = "Legacy rating mode";
+ public static final String LEGACY_RATING_SUB_CATEGORY = "Legacy rating mode";
+ public static final String LEGACY_RATING_MODE_ENABLED = "sonar.legacy.ratings.mode.enabled";
+
+ private LegacyRatingConstants() {
+ //class cannot be instantiated
+ }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingProperties.java b/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingProperties.java
new file mode 100644
index 00000000000..9e56594cf82
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingProperties.java
@@ -0,0 +1,55 @@
+/*
+ * 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.config;
+
+import java.util.Collections;
+import java.util.List;
+import org.sonar.api.PropertyType;
+import org.sonar.api.config.PropertyDefinition;
+
+import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_CATEGORY;
+import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_MODE_ENABLED;
+import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_SUB_CATEGORY;
+
+public final class LegacyRatingProperties {
+
+ private LegacyRatingProperties() {
+ }
+
+ public static List<PropertyDefinition> all() {
+ return Collections.singletonList(
+ PropertyDefinition.builder(LEGACY_RATING_MODE_ENABLED)
+ .defaultValue(Boolean.FALSE.toString())
+ .name("Enable legacy mode")
+ //TODO Need to add the correct link to the documentation once it is available
+ .description("Ratings have updated logic and have grades ranging from A to D, while the old scale ranges from A to E " +
+ "(<a href=\"\">read more about why</a>)." +
+ "<br><br>" +
+ "If you choose legacy mode, ratings and other counts will be calculated using the former logic. The old ratings scale (A-E) is " +
+ "deprecated and is scheduled for replacement by the new scale (A-D) in the next LTA.")
+ .type(PropertyType.BOOLEAN)
+ .category(LEGACY_RATING_CATEGORY)
+ .subCategory(LEGACY_RATING_SUB_CATEGORY)
+ .index(1)
+ .build()
+ );
+
+ }
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/config/LegacyRatingPropertiesTest.java b/sonar-core/src/test/java/org/sonar/core/config/LegacyRatingPropertiesTest.java
new file mode 100644
index 00000000000..4c23430a9ba
--- /dev/null
+++ b/sonar-core/src/test/java/org/sonar/core/config/LegacyRatingPropertiesTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.config;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class LegacyRatingPropertiesTest {
+ @Test
+ void all_shouldGetProperties() {
+ assertThat(LegacyRatingProperties.all()).hasSize(1);
+ }
+}