aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-11-19 10:28:55 -0600
committerSonarTech <sonartech@sonarsource.com>2019-12-09 20:46:17 +0100
commitebdae1d5b7916abb7e919c560b04841f0dfd21c6 (patch)
treedff14e70bbf3d19936e45f17ebc58dc48145586b /server/sonar-db-dao
parenta98070323ef55ce3934a564e0cf49a5e8fe03971 (diff)
downloadsonarqube-ebdae1d5b7916abb7e919c560b04841f0dfd21c6.tar.gz
sonarqube-ebdae1d5b7916abb7e919c560b04841f0dfd21c6.zip
SONAR-12673 Fix issue management
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java10
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/PrIssueDto.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java18
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java8
9 files changed, 20 insertions, 30 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java
index fd105f7492f..50df3f81289 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java
@@ -20,16 +20,6 @@
package org.sonar.db.component;
public enum BranchType {
-
- /**
- * Short-lived branch
- */
- SHORT,
-
BRANCH,
-
- /**
- * Pull request
- */
PULL_REQUEST
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
index 525e66fd1e5..d0f4c86bbe1 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
@@ -348,7 +348,7 @@ public class ComponentDao implements Dao {
}
/**
- * Returns components with open issues from branches that use a certain long living branch as reference (merge branch).
+ * Returns components with open issues from P/Rs that use a certain branch as reference (reference branch).
* Excludes components from the current branch.
*/
public List<KeyWithUuidDto> selectAllSiblingComponentKeysHavingOpenIssues(DbSession dbSession, String referenceBranchUuid, String currentBranchUuid) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/PrIssueDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/PrIssueDto.java
index cebbc06f3a0..6400398b5de 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/PrIssueDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/PrIssueDto.java
@@ -72,7 +72,7 @@ public final class PrIssueDto implements Serializable {
}
/**
- * Branch name for SLB, PR key for PR
+ * Branch name for BRANCH, PR key for PR
*/
public String getBranchKey() {
return branchKey;
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java
index 348cbbd9ce3..0c48dc66f64 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java
@@ -102,8 +102,8 @@ public class LiveMeasureDao implements Dao {
* If Main Branch = 100 LOCs and the "largest branch" is 120 LOCs, I'm expecting to consider the value 120.
* If Main Branch = 100 LOCs and the "largest branch" is 80 LOCs, I'm expecting to consider the value 100.
*/
- public long sumNclocOfBiggestLongLivingBranch(DbSession dbSession, SumNclocDbQuery dbQuery) {
- Long ncloc = mapper(dbSession).sumNclocOfBiggestLongLivingBranch(
+ public long sumNclocOfBiggestBranch(DbSession dbSession, SumNclocDbQuery dbQuery) {
+ Long ncloc = mapper(dbSession).sumNclocOfBiggestBranch(
NCLOC_KEY, KeyType.BRANCH, BranchType.BRANCH, dbQuery.getOrganizationUuid(), dbQuery.getOnlyPrivateProjects(), dbQuery.getProjectUuidToExclude());
return ncloc == null ? 0L : ncloc;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java
index d7bc5fa9625..75faf586934 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java
@@ -52,7 +52,7 @@ public interface LiveMeasureMapper {
@Param("baseUuidPath") String baseUuidPath,
ResultHandler<LiveMeasureDto> resultHandler);
- Long sumNclocOfBiggestLongLivingBranch(
+ Long sumNclocOfBiggestBranch(
@Param("ncloc") String nclocKey,
@Param("branch") KeyType branchOrPullRequest,
@Param("branchType") BranchType branchType,
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index 6b9fc43381f..6134fb1eda2 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -760,7 +760,7 @@
ON p.uuid = i.component_uuid
JOIN project_branches b
ON i.project_uuid = b.uuid
- AND (b.branch_type = 'SHORT' OR b.branch_type = 'PULL_REQUEST')
+ AND b.branch_type = 'PULL_REQUEST'
AND b.merge_branch_uuid = #{referenceBranchUuid,jdbcType=VARCHAR}
AND b.uuid != #{currentBranchUuid,jdbcType=VARCHAR}
AND i.status != 'CLOSED'
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml
index 49a4b93babf..5f1238f9161 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml
@@ -42,7 +42,7 @@
and lm.component_uuid = #{componentUuid, jdbcType=VARCHAR}
</select>
- <select id="sumNclocOfBiggestLongLivingBranch" parameterType="map" resultType="long">
+ <select id="sumNclocOfBiggestBranch" parameterType="map" resultType="long">
select sum(sumncloc.maxncloc) from (
select b.project_uuid as projectUuid, max(lm.value) as maxncloc
from live_measures lm
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
index 7f4071d45e4..464f4e8be6c 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
@@ -277,9 +277,9 @@ public class LiveMeasureDaoTest {
ComponentDto simpleProject = db.components().insertMainBranch(organization);
db.measures().insertLiveMeasure(simpleProject, ncloc, m -> m.setValue(10d));
- ComponentDto projectWithBiggerLongLivingBranch = db.components().insertMainBranch(organization);
- ComponentDto bigBranch = db.components().insertProjectBranch(projectWithBiggerLongLivingBranch, b -> b.setBranchType(BranchType.BRANCH));
- db.measures().insertLiveMeasure(projectWithBiggerLongLivingBranch, ncloc, m -> m.setValue(100d));
+ ComponentDto projectWithBiggerBranch = db.components().insertMainBranch(organization);
+ ComponentDto bigBranch = db.components().insertProjectBranch(projectWithBiggerBranch, b -> b.setBranchType(BranchType.BRANCH));
+ db.measures().insertLiveMeasure(projectWithBiggerBranch, ncloc, m -> m.setValue(100d));
db.measures().insertLiveMeasure(bigBranch, ncloc, m -> m.setValue(200d));
ComponentDto projectWithLinesButNoLoc = db.components().insertMainBranch(organization);
@@ -290,7 +290,7 @@ public class LiveMeasureDaoTest {
.setOnlyPrivateProjects(false)
.setOrganizationUuid(organization.getUuid())
.build();
- long result = underTest.sumNclocOfBiggestLongLivingBranch(db.getSession(), query);
+ long result = underTest.sumNclocOfBiggestBranch(db.getSession(), query);
assertThat(result).isEqualTo(10L + 200L);
}
@@ -303,7 +303,7 @@ public class LiveMeasureDaoTest {
.setOnlyPrivateProjects(false)
.setOrganizationUuid(db.getDefaultOrganization().getUuid())
.build();
- long result = underTest.sumNclocOfBiggestLongLivingBranch(db.getSession(), query);
+ long result = underTest.sumNclocOfBiggestBranch(db.getSession(), query);
assertThat(result).isEqualTo(0L);
}
@@ -316,9 +316,9 @@ public class LiveMeasureDaoTest {
ComponentDto simpleProject = db.components().insertMainBranch(organization);
db.measures().insertLiveMeasure(simpleProject, ncloc, m -> m.setValue(10d));
- ComponentDto projectWithBiggerLongLivingBranch = db.components().insertMainBranch(organization);
- ComponentDto bigBranch = db.components().insertProjectBranch(projectWithBiggerLongLivingBranch, b -> b.setBranchType(BranchType.BRANCH));
- db.measures().insertLiveMeasure(projectWithBiggerLongLivingBranch, ncloc, m -> m.setValue(100d));
+ ComponentDto projectWithBiggerBranch = db.components().insertMainBranch(organization);
+ ComponentDto bigBranch = db.components().insertProjectBranch(projectWithBiggerBranch, b -> b.setBranchType(BranchType.BRANCH));
+ db.measures().insertLiveMeasure(projectWithBiggerBranch, ncloc, m -> m.setValue(100d));
db.measures().insertLiveMeasure(bigBranch, ncloc, m -> m.setValue(200d));
ComponentDto projectToExclude = db.components().insertMainBranch(organization);
@@ -331,7 +331,7 @@ public class LiveMeasureDaoTest {
.setProjectUuidToExclude(projectToExclude.uuid())
.setOnlyPrivateProjects(false)
.build();
- long result = underTest.sumNclocOfBiggestLongLivingBranch(db.getSession(), query);
+ long result = underTest.sumNclocOfBiggestBranch(db.getSession(), query);
assertThat(result).isEqualTo(10L + 200L);
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
index 149ae2e229a..c3babddf4ea 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
@@ -165,7 +165,7 @@ public class PurgeDaoTest {
when(system2.now()).thenReturn(new Date().getTime());
RuleDefinitionDto rule = db.rules().insert();
ComponentDto project = db.components().insertMainBranch();
- ComponentDto longBranch = db.components().insertProjectBranch(project);
+ ComponentDto nonMainBranch = db.components().insertProjectBranch(project);
ComponentDto recentPullRequest = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST));
// pull request with other components and issues, updated 31 days ago
@@ -181,7 +181,7 @@ public class PurgeDaoTest {
underTest.purge(dbSession, newConfigurationWith30Days(System2.INSTANCE, project.uuid(), project.uuid()), PurgeListener.EMPTY, new PurgeProfiler());
dbSession.commit();
- assertThat(uuidsIn("projects")).containsOnly(project.uuid(), longBranch.uuid(), recentPullRequest.uuid());
+ assertThat(uuidsIn("projects")).containsOnly(project.uuid(), nonMainBranch.uuid(), recentPullRequest.uuid());
}
@Test
@@ -189,7 +189,7 @@ public class PurgeDaoTest {
when(system2.now()).thenReturn(new Date().getTime());
RuleDefinitionDto rule = db.rules().insert();
ComponentDto project = db.components().insertMainBranch();
- ComponentDto longBranch = db.components().insertProjectBranch(project);
+ ComponentDto nonMainBranch = db.components().insertProjectBranch(project);
when(system2.now()).thenReturn(DateUtils.addDays(new Date(), -31).getTime());
@@ -208,7 +208,7 @@ public class PurgeDaoTest {
dbSession.commit();
// branch1 wasn't deleted since it was being analyzed!
- assertThat(uuidsIn("projects")).containsOnly(project.uuid(), longBranch.uuid(), branch1.uuid());
+ assertThat(uuidsIn("projects")).containsOnly(project.uuid(), nonMainBranch.uuid(), branch1.uuid());
}
@Test