]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11525 message fixes
authorMichal Duda <michal.duda@sonarsource.com>
Thu, 6 Dec 2018 11:41:07 +0000 (12:41 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Jan 2019 08:43:06 +0000 (09:43 +0100)
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/DbVersion76.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v76/MigrateModuleProperties.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v76/MigrateModulePropertiesTest.java
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectServerSettingsProvider.java

index 0cdfeaf5f99fbc058441f115c35739c4f675dff7..550e9b6286da4af4be4d3e65747cb07bd37ba948 100644 (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);
   }
index 8c49e2c62fc338b9664ec78e25754659a4ead707..0194084578c0d1bc98c9d24d894ba9853e7ef883 100644 (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 " +
index 4692e49ef14db357a569df2ff87d350236c4a891..5dd8652de5507d8bcaeeb1b240d620c3e356ba68 100644 (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 " +
index 82b69240566f32eb95de0b2233256179f0c23402..d890b865ae5ba716dfb477d71022038fc79f9c8d 100644 (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)
index 47d4f578ed65a0f0a35ef3d6520c01d5701661b1..a0545e1dd5b03a2ac6a945712b331a4d560bdcf8 100644 (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;