From 1c6140eb0fcf46beeb5e9785689e19c45ff135a8 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Fri, 25 Aug 2017 16:31:04 +0200 Subject: [PATCH] SONAR-9721 Send ncloc by language in telemetry report --- .../java/org/sonar/server/telemetry/TelemetryDaemon.java | 4 +++- .../org/sonar/server/telemetry/TelemetryDaemonTest.java | 6 ++++-- .../org/sonar/server/telemetry/telemetry-example.json | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java b/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java index 3b907b2020e..24ae7cc22cb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java +++ b/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java @@ -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()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java b/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java index f0942765170..0c5f6c179b3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java @@ -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(); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/telemetry/telemetry-example.json b/server/sonar-server/src/test/resources/org/sonar/server/telemetry/telemetry-example.json index a74d0d2e5f1..b17a4aab7c4 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/telemetry/telemetry-example.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/telemetry/telemetry-example.json @@ -10,9 +10,14 @@ "projectCount": 2, "lines": 500, "ncloc": 300, - "projectLanguageDistribution": { + "projectCountByLanguage": { "java": 2, "kotlin": 1, "js": 1 + }, + "nclocByLanguage": { + "java": 500, + "kotlin": 2500, + "js": 50 } } -- 2.39.5