Browse Source

SONAR-11525 message fixes

tags/7.6
Michal Duda 5 years ago
parent
commit
5002606768

+ 1
- 1
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76.java View File

@@ -29,7 +29,7 @@ public class DbVersion76 implements DbVersion {
registry
.add(2500, "Create table USER_PROPERTIES", CreateUserPropertiesTable.class)
.add(2501, "Add index in table USER_PROPERTIES", AddUniqueIndexInUserPropertiesTable.class)
.add(2502, "Move module and directory properties to a project level property", MigrateModuleProperties.class)
.add(2502, "Archive module properties in a new project level property", MigrateModuleProperties.class)
.add(2505, "Fix the direction values of certain metrics (prepare for migration of conditions)", FixDirectionOfMetrics.class)
.add(2506, "Migrate quality gate conditions using warning, period and no more supported operations", MigrateNoMoreUsedQualityGateConditions.class);
}

+ 5
- 4
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateModuleProperties.java View File

@@ -20,6 +20,7 @@
package org.sonar.server.platform.db.migration.version.v76;

import java.sql.SQLException;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import org.sonar.api.utils.System2;
import org.sonar.db.Database;
@@ -80,12 +81,12 @@ public class MigrateModuleProperties extends DataChange {
if (currentModuleUuid.get() != null && builder.length() != 0) {
builder.append("\n");
}
builder.append("# previous settings for sub-project ").append(projectName).append("::").append(moduleName).append("\n");
builder.append("# Settings from '").append(projectName).append("::").append(moduleName).append("'\n");
currentModuleUuid.set(moduleUuid);
}

String propertyValue = propertyTextValue == null ? propertyClobValue : propertyTextValue;
builder.append(propertyKey).append("=").append(propertyValue).append("\n");
Optional.ofNullable(Optional.ofNullable(propertyTextValue).orElse(propertyClobValue))
.ifPresent(value -> builder.append(propertyKey).append("=").append(value).append("\n"));
});

if (builder.length() > 0) {
@@ -105,7 +106,7 @@ public class MigrateModuleProperties extends DataChange {
}

private static void removeModuleProperties(Context context) throws SQLException {
MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("remove module properties");
MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("module level properties");
massUpdate.select("select prop.id as property_id " +
"from properties prop " +
"left join projects mod on mod.id = prop.resource_id " +

+ 11
- 6
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest.java View File

@@ -53,6 +53,7 @@ public class MigrateModulePropertiesTest {
underTest.execute();

verifyMultiModuleProjectMigration();
assertThat(getRemainingProperties()).hasSize(3);
}

@Test
@@ -63,8 +64,7 @@ public class MigrateModulePropertiesTest {
underTest.execute();

verifyMultiModuleProjectMigration();
List<Map<String, Object>> remainingProperties = db.select("select ID from properties");
assertThat(remainingProperties).hasSize(3);
assertThat(getRemainingProperties()).hasSize(3);
}

@Test
@@ -93,6 +93,11 @@ public class MigrateModulePropertiesTest {

verifyMultiModuleProjectMigration();
verifySecondMultiModuleProjectMigration();
assertThat(getRemainingProperties()).hasSize(5);
}

private List<Map<String, Object>> getRemainingProperties() {
return db.select("select ID from properties");
}

private void insertComponent(long id, String uuid, @Nullable String rootUuid, String projectUuid, String qualifier, String name) {
@@ -137,15 +142,15 @@ public class MigrateModulePropertiesTest {
}

private void verifyMultiModuleProjectMigration() {
final String expectedResult = "# previous settings for sub-project Multi-module project::Module\n" +
final String expectedResult = "# Settings from 'Multi-module project::Module'\n" +
"sonar.coverage.exclusions=ModuleA.java\n" +
"sonar.cpd.exclusions=ModuleB.java\n" +
"\n" +
"# previous settings for sub-project Multi-module project::Submodule 1\n" +
"# Settings from 'Multi-module project::Submodule 1'\n" +
"sonar.coverage.exclusions=Module1A.java\n" +
"sonar.cpd.exclusions=Moddule1B.java\n" +
"\n" +
"# previous settings for sub-project Multi-module project::Submodule 2\n" +
"# Settings from 'Multi-module project::Submodule 2'\n" +
"sonar.coverage.exclusions=Module2A.java\n" +
"sonar.cpd.exclusions=Module2B.java\n";

@@ -169,7 +174,7 @@ public class MigrateModulePropertiesTest {
}

private void verifySecondMultiModuleProjectMigration() {
final String expectedResult = "# previous settings for sub-project Another multi-module project::Module X\n" +
final String expectedResult = "# Settings from 'Another multi-module project::Module X'\n" +
"sonar.coverage.exclusions=InModule.java\n";

List<Map<String, Object>> properties = db.select(String.format("select ID, TEXT_VALUE, CLOB_VALUE " +

+ 3
- 3
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java View File

@@ -64,9 +64,9 @@ public class CorePropertyDefinitions {
defs.addAll(asList(
PropertyDefinition.builder(CoreProperties.MODULE_LEVEL_ARCHIVED_SETTINGS)
.name("Archived Sub-Projects Settings")
.description("DEPRECATED - Recap of the properties that were previously configured at sub-project / module level. " +
"These properties are not used anymore and should now be configured at project level. " +
"Set this parameter to empty to prevent the analysis from displaying a warning.")
.description("DEPRECATED - List of the properties that were previously configured at sub-project / module level. " +
"These properties are not used anymore and should now be configured at project level. When you've made the " +
"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)

+ 4
- 2
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectServerSettingsProvider.java View File

@@ -33,8 +33,10 @@ public class ProjectServerSettingsProvider extends ProviderAdapter {

private static final Logger LOG = Loggers.get(ProjectConfigurationProvider.class);

private static final String MODULE_LEVEL_ARCHIVED_SETTINGS_WARNING = String.format("Please configure the settings listed in " +
"`%s` at project level and remove that setting to prevent the analysis from displaying a warning.", CoreProperties.MODULE_LEVEL_ARCHIVED_SETTINGS);
private static final String MODULE_LEVEL_ARCHIVED_SETTINGS_WARNING = "Settings that were previously configured at " +
"sub-project level are not used anymore. Transition the settings listed in ‘General Settings -> General -> " +
"Archived Sub-Projects Settings' at project level, and clear the property to prevent the analysis from " +
"displaying this warning.";

private ProjectServerSettings singleton = null;


Loading…
Cancel
Save