aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-09-01 13:46:51 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-09-12 11:34:57 +0200
commit4f4c33f79d27c198d86e105637387c58ca91c166 (patch)
tree4c08a19da58ee9ee951482e62f6bd05dd1527150
parenta314c0cd2862cefdc5fb9aacf0612a5560b0f32a (diff)
downloadsonarqube-4f4c33f79d27c198d86e105637387c58ca91c166.tar.gz
sonarqube-4f4c33f79d27c198d86e105637387c58ca91c166.zip
SONAR-9616 Component name is set to public key when empty
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java13
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java14
2 files changed, 15 insertions, 12 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java
index ec277ceac4f..275bc96e7b7 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java
@@ -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())
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java
index ce41606865c..663125a229e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java
@@ -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) {