aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-08-25 16:31:04 +0200
committerTeryk Bellahsene <teryk@users.noreply.github.com>2017-08-30 16:24:53 +0200
commit1c6140eb0fcf46beeb5e9785689e19c45ff135a8 (patch)
tree0eaa3cf4a649923d20a8d9fe23cf7653c29a124a /server
parentf9de48b31ce9824bf9fa00a82c293fd8d5353901 (diff)
downloadsonarqube-1c6140eb0fcf46beeb5e9785689e19c45ff135a8.tar.gz
sonarqube-1c6140eb0fcf46beeb5e9785689e19c45ff135a8.zip
SONAR-9721 Send ncloc by language in telemetry report
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java6
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/telemetry/telemetry-example.json7
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
}
}