value: 'true',
},
{
- key: 'sonar.old_world',
- value: 'false',
+ key: SettingsKey.MQRMode,
+ value: 'true',
},
];
['Project', '/projects', ComponentQualifier.Project],
['Portfolios', '/portfolios', ComponentQualifier.Portfolio],
])('should not render on %s page if isLegacy', (_, path, qualifier) => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
render(path);
expect(ui.alert.get()).toBeInTheDocument();
expect(ui.alertText(qualifier).get()).toBeInTheDocument();
});
it('should correctly render the default overview and navigation in legacy mode', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
const { ui, user } = getPageObject();
renderMeasuresApp();
});
it('should show old measures and no flag message if no rating measures and legacy mode', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
measuresHandler.deleteComponentMeasure(
'foo',
MetricKey.software_quality_maintainability_rating,
});
it('should display old measures if in legacy mode', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
const { user, ui } = getPageObjects();
renderBranchOverview();
MetricKey.software_quality_maintainability_rating,
);
measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_reliability_rating);
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
const { user, ui } = getPageObjects();
renderBranchOverview();
});
it('should not show gaps message and metric change button in legacy mode', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
timeMachineHandler.setMeasureHistory([
mockMeasureHistory({
metric: MetricKey.reliability_rating,
});
it('should show legacy filters', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
renderPageSidebar();
expect(await screen.findAllByText(/projects.facets.rating_option/)).toHaveLength(20);
});
it('should show non legacy filters', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'false');
+ settingsHandler.set(SettingsKey.MQRMode, 'true');
renderPageSidebar();
expect(await screen.findAllByText(/projects.facets.rating_option/)).toHaveLength(20);
});
it('should not display awaiting analysis badge if legacy mode is enabled', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
renderProjectCard({
...PROJECT,
measures: {
});
it('should not display new values if legacy mode is enabled', async () => {
- settingsHandler.set(SettingsKey.LegacyMode, 'true');
+ settingsHandler.set(SettingsKey.MQRMode, 'false');
measuresHandler.registerComponentMeasures({
[PROJECT.key]: {
...newRatings,
export const useIsLegacyCCTMode = () => {
return useGetValueQuery(
- { key: SettingsKey.LegacyMode },
- { staleTime: Infinity, select: (data) => data?.value === 'true' },
+ { key: SettingsKey.MQRMode },
+ { staleTime: Infinity, select: (data) => data?.value === 'false' },
);
};
LicenceRemainingLocNotificationThreshold = 'sonar.license.notifications.remainingLocThreshold',
TokenMaxAllowedLifetime = 'sonar.auth.token.max.allowed.lifetime',
QPAdminCanDisableInheritedRules = 'sonar.qualityProfiles.allowDisableInheritedRules',
- LegacyMode = 'sonar.legacy.ratings.mode.enabled',
+ MQRMode = 'sonar.multi-quality-mode.enabled',
CodeSuggestion = 'sonar.ai.suggestions.enabled',
}
import org.sonar.server.platform.db.CheckAnyonePermissionsAtStartup;
import org.sonar.server.platform.telemetry.ProjectCppAutoconfigTelemetryProvider;
import org.sonar.server.platform.telemetry.TelemetryFipsEnabledProvider;
+import org.sonar.server.platform.telemetry.TelemetryMQRModePropertyProvider;
import org.sonar.server.platform.telemetry.TelemetryNclocProvider;
import org.sonar.server.platform.telemetry.TelemetryPortfolioConfidentialFlagProvider;
import org.sonar.server.platform.telemetry.TelemetryUserEnabledProvider;
// new telemetry metrics
ProjectCppAutoconfigTelemetryProvider.class,
TelemetryVersionProvider.class,
+ TelemetryMQRModePropertyProvider.class,
TelemetryNclocProvider.class,
TelemetryUserEnabledProvider.class,
TelemetryFipsEnabledProvider.class,
--- /dev/null
+/*
+ * 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.server.platform.telemetry;
+
+import java.util.Optional;
+import org.sonar.db.DbClient;
+import org.sonar.db.property.PropertyDto;
+import org.sonar.telemetry.core.Dimension;
+import org.sonar.telemetry.core.Granularity;
+import org.sonar.telemetry.core.TelemetryDataProvider;
+import org.sonar.telemetry.core.TelemetryDataType;
+
+import static org.sonar.core.config.MQRModeConstants.MULTI_QUALITY_MODE_ENABLED;
+import static org.sonar.telemetry.core.Dimension.INSTALLATION;
+import static org.sonar.telemetry.core.Granularity.WEEKLY;
+import static org.sonar.telemetry.core.TelemetryDataType.BOOLEAN;
+
+public class TelemetryMQRModePropertyProvider implements TelemetryDataProvider<Boolean> {
+ private final DbClient dbClient;
+
+ public TelemetryMQRModePropertyProvider(DbClient dbClient) {
+ this.dbClient = dbClient;
+ }
+
+ @Override
+ public String getMetricKey() {
+ return "multi_quality_rule_mode_enabled";
+ }
+
+ @Override
+ public Dimension getDimension() {
+ return INSTALLATION;
+ }
+
+ @Override
+ public Granularity getGranularity() {
+ return WEEKLY;
+ }
+
+ @Override
+ public TelemetryDataType getType() {
+ return BOOLEAN;
+ }
+
+ @Override
+ public Optional<Boolean> getValue() {
+ PropertyDto property = dbClient.propertiesDao().selectGlobalProperty(MULTI_QUALITY_MODE_ENABLED);
+ return Optional.of(property != null && Boolean.parseBoolean(property.getValue()));
+ }
+}
--- /dev/null
+/*
+ * 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.server.platform.telemetry;
+
+import java.util.Optional;
+import java.util.stream.Stream;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.sonar.db.DbClient;
+import org.sonar.db.property.PropertiesDao;
+import org.sonar.db.property.PropertyDto;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.sonar.core.config.MQRModeConstants.MULTI_QUALITY_MODE_ENABLED;
+import static org.sonar.telemetry.core.Dimension.INSTALLATION;
+import static org.sonar.telemetry.core.Granularity.WEEKLY;
+import static org.sonar.telemetry.core.TelemetryDataType.BOOLEAN;
+
+class TelemetryMQRModePropertyProviderTest {
+ private final DbClient dbClient = mock();
+ private final PropertiesDao propertiesDao = mock();
+ private final TelemetryMQRModePropertyProvider underTest = new TelemetryMQRModePropertyProvider(dbClient);
+
+ @ParameterizedTest
+ @MethodSource("getValues")
+ void getter_should_return_correct_values(Boolean value, Boolean expected) {
+ when(dbClient.propertiesDao()).thenReturn(propertiesDao);
+ if (value == null) {
+ when(dbClient.propertiesDao().selectGlobalProperty(MULTI_QUALITY_MODE_ENABLED))
+ .thenReturn(null);
+ } else {
+ when(dbClient.propertiesDao().selectGlobalProperty(MULTI_QUALITY_MODE_ENABLED))
+ .thenReturn(new PropertyDto().setValue(value.toString()));
+ }
+
+ assertEquals("multi_quality_rule_mode_enabled", underTest.getMetricKey());
+ assertEquals(INSTALLATION, underTest.getDimension());
+ assertEquals(WEEKLY, underTest.getGranularity());
+ assertEquals(BOOLEAN, underTest.getType());
+ assertEquals(Optional.of(expected), underTest.getValue());
+ }
+
+ public static Stream<Arguments> getValues() {
+ return Stream.of(
+ Arguments.of(true, true),
+ Arguments.of(false, false),
+ Arguments.of(null, false)
+ );
+ }
+
+}
defs.addAll(PurgeProperties.all());
defs.addAll(EmailSettings.definitions());
defs.addAll(ScannerProperties.all());
+ defs.addAll(MQRModeProperties.all());
defs.addAll(asList(
PropertyDefinition.builder(CoreProperties.MODULE_LEVEL_ARCHIVED_SETTINGS)
--- /dev/null
+/*
+ * 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 MQRModeConstants {
+
+ public static final String UI_MODE = "Mode";
+ public static final String UI_MODE_SUB_CATEGORY = "Mode";
+ public static final String MULTI_QUALITY_MODE_ENABLED = "sonar.multi-quality-mode.enabled";
+
+ private MQRModeConstants() {
+ //class cannot be instantiated
+ }
+}
--- /dev/null
+/*
+ * 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.MQRModeConstants.UI_MODE;
+import static org.sonar.core.config.MQRModeConstants.UI_MODE_SUB_CATEGORY;
+import static org.sonar.core.config.MQRModeConstants.MULTI_QUALITY_MODE_ENABLED;
+
+public final class MQRModeProperties {
+
+ private MQRModeProperties() {
+ }
+
+ public static List<PropertyDefinition> all() {
+ return Collections.singletonList(
+ PropertyDefinition.builder(MULTI_QUALITY_MODE_ENABLED)
+ .defaultValue(Boolean.FALSE.toString())
+ .name("Enable Multi-Quality Rule Mode")
+ .description("Aims to more accurately represent the impact software has on all software qualities. " +
+ "It does this by mapping rules to every software quality they can impact, not just the one " +
+ "they impact most significantly. Each rule has a separate severity " +
+ "for the impact it has on each quality that it has been mapped to. \n" +
+ "This approach focuses on ensuring the impact on all software qualities is clear, " +
+ "not just the most severe one.")
+ .type(PropertyType.BOOLEAN)
+ .category(UI_MODE)
+ .subCategory(UI_MODE_SUB_CATEGORY)
+ .index(1)
+ .build()
+ );
+
+ }
+}
--- /dev/null
+/*
+ * 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 MQRModePropertiesTest {
+ @Test
+ void all_shouldGetProperties() {
+ assertThat(MQRModeProperties.all()).hasSize(1);
+ }
+}