diff options
author | Pierre <pierre.guillot@sonarsource.com> | 2023-03-28 10:16:41 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-03-30 20:03:08 +0000 |
commit | 0d7f6cc7158db5efd4694515f3448970dcbe1140 (patch) | |
tree | 15858586587e6724217cf53de139cdef1e231b44 /server/sonar-webserver-core | |
parent | d6bd659df4ab570421273f5d30facb8334cf87be (diff) | |
download | sonarqube-0d7f6cc7158db5efd4694515f3448970dcbe1140.tar.gz sonarqube-0d7f6cc7158db5efd4694515f3448970dcbe1140.zip |
SONAR-18872 improve total ncloc computation10.0.0.68432
Diffstat (limited to 'server/sonar-webserver-core')
2 files changed, 2 insertions, 7 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/StatisticsSupport.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/StatisticsSupport.java index 29325634dce..4d8f07d5c06 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/StatisticsSupport.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/StatisticsSupport.java @@ -21,7 +21,6 @@ package org.sonar.server.platform; import org.sonar.db.DbClient; import org.sonar.db.DbSession; -import org.sonar.db.measure.SumNclocDbQuery; public class StatisticsSupport { @@ -33,10 +32,7 @@ public class StatisticsSupport { public long getLinesOfCode(){ try (DbSession dbSession = dbClient.openSession(false)) { - SumNclocDbQuery query = SumNclocDbQuery.builder() - .setOnlyPrivateProjects(false) - .build(); - return dbClient.liveMeasureDao().sumNclocOfBiggestBranch(dbSession, query); + return dbClient.projectDao().getNclocSum(dbSession); } } } diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/StatisticsSupportTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/StatisticsSupportTest.java index 872862a0699..052ab11bbea 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/StatisticsSupportTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/StatisticsSupportTest.java @@ -22,7 +22,6 @@ package org.sonar.server.platform; import org.junit.Test; import org.sonar.db.DbClient; import org.sonar.db.DbSession; -import org.sonar.db.measure.SumNclocDbQuery; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -37,7 +36,7 @@ public class StatisticsSupportTest { @Test public void should_return_metric_from_liveMeasureDao() { - when(dbClient.liveMeasureDao().sumNclocOfBiggestBranch(any(DbSession.class), any(SumNclocDbQuery.class))).thenReturn(1800999L); + when(dbClient.projectDao().getNclocSum(any(DbSession.class))).thenReturn(1800999L); long linesOfCode = statisticsSupport.getLinesOfCode(); |