]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9616 Component name is set to public key when empty
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 1 Sep 2017 11:46:51 +0000 (13:46 +0200)
committerJanos Gyerik <janos.gyerik@sonarsource.com>
Tue, 12 Sep 2017 09:34:57 +0000 (11:34 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java

index ec277ceac4f1212878f1cfbbab16a950cf2163eb..275bc96e7b79f5eff20bffbbf7ca9c3c0af92239 100644 (file)
@@ -93,10 +93,11 @@ public class ComponentTreeBuilder {
       case PROJECT:
         String projectKey = keyGenerator.generateKey(component, null);
         String uuid = uuidSupplier.apply(projectKey);
+        String projectPublicKey = publicKeyGenerator.generateKey(component, null);
         return ComponentImpl.builder(Component.Type.PROJECT)
           .setUuid(uuid)
           .setKey(projectKey)
-          .setPublicKey(publicKeyGenerator.generateKey(component, null))
+          .setPublicKey(projectPublicKey)
           .setName(nameOfProject(component))
           .setStatus(convertStatus(component.getStatus()))
           .setDescription(trimToNull(component.getDescription()))
@@ -108,11 +109,12 @@ public class ComponentTreeBuilder {
 
       case MODULE:
         String moduleKey = keyGenerator.generateKey(component, null);
+        String modulePublicKey = publicKeyGenerator.generateKey(component, null);
         return ComponentImpl.builder(Component.Type.MODULE)
           .setUuid(uuidSupplier.apply(moduleKey))
           .setKey(moduleKey)
-          .setPublicKey(publicKeyGenerator.generateKey(component, null))
-          .setName(nameOfOthers(component, moduleKey))
+          .setPublicKey(modulePublicKey)
+          .setName(nameOfOthers(component, modulePublicKey))
           .setStatus(convertStatus(component.getStatus()))
           .setDescription(trimToNull(component.getDescription()))
           .setReportAttributes(createAttributesBuilder(component).build())
@@ -122,11 +124,12 @@ public class ComponentTreeBuilder {
       case DIRECTORY:
       case FILE:
         String key = keyGenerator.generateKey(closestModule, component);
+        String publicKey = publicKeyGenerator.generateKey(closestModule, component);
         return ComponentImpl.builder(convertDirOrFileType(component.getType()))
           .setUuid(uuidSupplier.apply(key))
           .setKey(key)
-          .setPublicKey(publicKeyGenerator.generateKey(closestModule, component))
-          .setName(nameOfOthers(component, key))
+          .setPublicKey(publicKey)
+          .setName(nameOfOthers(component, publicKey))
           .setStatus(convertStatus(component.getStatus()))
           .setDescription(trimToNull(component.getDescription()))
           .setReportAttributes(createAttributesBuilder(component).build())
index ce41606865c29e5121cad2375a28586eb5bc2196..663125a229ece20358d2de9c348a9f811479c270 100644 (file)
@@ -225,17 +225,17 @@ public class ComponentTreeBuilderTest {
     Component root = call(project);
 
     Component module = root.getChildren().iterator().next();
-    assertThat(module.getName()).isEqualTo("generated_M");
+    assertThat(module.getName()).isEqualTo("public_M");
 
     Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getName()).isEqualTo("generated_M:src/js");
+    assertThat(directory.getName()).isEqualTo("public_M:src/js");
 
     Component file = directory.getChildren().iterator().next();
-    assertThat(file.getName()).isEqualTo("generated_M:src/js/Foo.js");
+    assertThat(file.getName()).isEqualTo("public_M:src/js/Foo.js");
   }
 
   @Test
-  public void names_of_module_directory_and_file_are_keys_if_names_are_empty_in_report() {
+  public void names_of_module_directory_and_file_are_public_keys_if_names_are_empty_in_report() {
     ScannerReport.Component project = newBuilder()
       .setType(PROJECT)
       .setKey(projectInDb.getKey())
@@ -264,13 +264,13 @@ public class ComponentTreeBuilderTest {
     Component root = call(project);
 
     Component module = root.getChildren().iterator().next();
-    assertThat(module.getName()).isEqualTo("generated_M");
+    assertThat(module.getName()).isEqualTo("public_M");
 
     Component directory = module.getChildren().iterator().next();
-    assertThat(directory.getName()).isEqualTo("generated_M:src/js");
+    assertThat(directory.getName()).isEqualTo("public_M:src/js");
 
     Component file = directory.getChildren().iterator().next();
-    assertThat(file.getName()).isEqualTo("generated_M:src/js/Foo.js");
+    assertThat(file.getName()).isEqualTo("public_M:src/js/Foo.js");
   }
 
   private void assertThatFileAttributesAreNotSet(Component root) {