]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9721 Send ncloc by language in telemetry report
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 25 Aug 2017 14:31:04 +0000 (16:31 +0200)
committerTeryk Bellahsene <teryk@users.noreply.github.com>
Wed, 30 Aug 2017 14:24:53 +0000 (16:24 +0200)
server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java
server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
server/sonar-server/src/test/resources/org/sonar/server/telemetry/telemetry-example.json

index 3b907b2020eceb225aa8a9f710b00f9b9b11e638..24ae7cc22cb589ba70d382f2b9c607a3964b12a5 100644 (file)
@@ -164,8 +164,10 @@ public class TelemetryDaemon implements Startable {
       writer.prop("projectCount", statistics.getProjectCount());
       writer.prop(LINES_KEY, statistics.getLines());
       writer.prop(NCLOC_KEY, statistics.getNcloc());
-      writer.name("projectLanguageDistribution");
+      writer.name("projectCountByLanguage");
       writer.valueObject(statistics.getProjectCountByLanguage());
+      writer.name("nclocByLanguage");
+      writer.valueObject(statistics.getNclocByLanguage());
       writer.endObject();
     }
     telemetryClient.upload(json.toString());
index f09427651709620825ab162a4509434341437612..0c5f6c179b3e7cd6ddceed2557193cab3945cf30 100644 (file)
@@ -107,10 +107,12 @@ public class TelemetryDaemonTest {
     es.putDocuments(ProjectMeasuresIndexDefinition.INDEX_TYPE_PROJECT_MEASURES,
       new ProjectMeasuresDoc().setId(randomAlphanumeric(20))
         .setMeasures(Arrays.asList(newMeasure("lines", 200), newMeasure("ncloc", 100), newMeasure("coverage", 80)))
-        .setLanguages(Arrays.asList("java", "js")),
+        .setLanguages(Arrays.asList("java", "js"))
+        .setNclocLanguageDistributionFromMap(ImmutableMap.of("java", 200, "js", 50)),
       new ProjectMeasuresDoc().setId(randomAlphanumeric(20))
         .setMeasures(Arrays.asList(newMeasure("lines", 300), newMeasure("ncloc", 200), newMeasure("coverage", 80)))
-        .setLanguages(Arrays.asList("java", "kotlin")));
+        .setLanguages(Arrays.asList("java", "kotlin"))
+        .setNclocLanguageDistributionFromMap(ImmutableMap.of("java", 300, "kotlin", 2500)));
 
     underTest.start();
 
index a74d0d2e5f1f0af0258a112d67f90d93e7074ab5..b17a4aab7c40d2e5c6e22b7ddf1fb1d4337c1ccd 100644 (file)
   "projectCount": 2,
   "lines": 500,
   "ncloc": 300,
-  "projectLanguageDistribution": {
+  "projectCountByLanguage": {
     "java": 2,
     "kotlin": 1,
     "js": 1
+  },
+  "nclocByLanguage": {
+    "java": 500,
+    "kotlin": 2500,
+    "js": 50
   }
 }