aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2023-04-07 11:20:58 -0500
committersonartech <sonartech@sonarsource.com>2023-04-12 20:03:19 +0000
commitd471398ec43363960f179e490681fcab237cdbc0 (patch)
tree8c25b56da04b7a6c2e4e86d7e04bd22495376fa6 /server/sonar-server-common
parent0cacb9813afdd9abce8931d03f7e15f5fab40930 (diff)
downloadsonarqube-d471398ec43363960f179e490681fcab237cdbc0.tar.gz
sonarqube-d471398ec43363960f179e490681fcab237cdbc0.zip
SONAR-18860 Remove use of main_branch_project_uuid
Diffstat (limited to 'server/sonar-server-common')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java30
1 files changed, 14 insertions, 16 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java
index a7101901c6c..907d1d55465 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/index/IssueIteratorForSingleChunk.java
@@ -74,9 +74,10 @@ class IssueIteratorForSingleChunk implements IssueIterator {
"c.path",
"c.scope",
"c.branch_uuid",
- "c.main_branch_project_uuid",
+ "pb.is_main",
+ "pb.project_uuid",
- // column 21
+ // column 22
"i.tags",
"i.issue_type",
"r.security_standards",
@@ -86,7 +87,8 @@ class IssueIteratorForSingleChunk implements IssueIterator {
private static final String SQL_ALL = "select " + StringUtils.join(FIELDS, ",") + " from issues i " +
"inner join rules r on r.uuid = i.rule_uuid " +
- "inner join components c on c.uuid = i.component_uuid ";
+ "inner join components c on c.uuid = i.component_uuid " +
+ "inner join project_branches pb on c.branch_uuid = pb.uuid ";
private static final String SQL_NEW_CODE_JOIN = "left join new_code_reference_issues n on n.issue_key = i.kee ";
@@ -214,20 +216,16 @@ class IssueIteratorForSingleChunk implements IssueIterator {
doc.setFilePath(filePath);
doc.setDirectoryPath(extractDirPath(doc.filePath(), scope));
String branchUuid = rs.getString(17);
- String mainBranchProjectUuid = DatabaseUtils.getString(rs, 18);
+ boolean isMainBranch = rs.getBoolean( 18);
+ String projectUuid = rs.getString(19);
doc.setBranchUuid(branchUuid);
- if (mainBranchProjectUuid == null) {
- doc.setProjectUuid(branchUuid);
- doc.setIsMainBranch(true);
- } else {
- doc.setProjectUuid(mainBranchProjectUuid);
- doc.setIsMainBranch(false);
- }
- String tags = rs.getString(19);
+ doc.setIsMainBranch(isMainBranch);
+ doc.setProjectUuid(projectUuid);
+ String tags = rs.getString(20);
doc.setTags(IssueIteratorForSingleChunk.TAGS_SPLITTER.splitToList(tags == null ? "" : tags));
- doc.setType(RuleType.valueOf(rs.getInt(20)));
+ doc.setType(RuleType.valueOf(rs.getInt(21)));
- SecurityStandards securityStandards = fromSecurityStandards(deserializeSecurityStandardsString(rs.getString(21)));
+ SecurityStandards securityStandards = fromSecurityStandards(deserializeSecurityStandardsString(rs.getString(22)));
SecurityStandards.SQCategory sqCategory = securityStandards.getSqCategory();
doc.setOwaspTop10(securityStandards.getOwaspTop10());
doc.setOwaspTop10For2021(securityStandards.getOwaspTop10For2021());
@@ -239,8 +237,8 @@ class IssueIteratorForSingleChunk implements IssueIterator {
doc.setSonarSourceSecurityCategory(sqCategory);
doc.setVulnerabilityProbability(sqCategory.getVulnerability());
- doc.setScope(Qualifiers.UNIT_TEST_FILE.equals(rs.getString(22)) ? IssueScope.TEST : IssueScope.MAIN);
- doc.setIsNewCodeReference(!isNullOrEmpty(rs.getString(23)));
+ doc.setScope(Qualifiers.UNIT_TEST_FILE.equals(rs.getString(23)) ? IssueScope.TEST : IssueScope.MAIN);
+ doc.setIsNewCodeReference(!isNullOrEmpty(rs.getString(24)));
return doc;
}