aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis/src/main
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2022-05-13 09:43:38 +0200
committersonartech <sonartech@sonarsource.com>2022-05-13 20:02:49 +0000
commit46543413d0cc6188a95260ec9a1c0d9b5da26e82 (patch)
tree08d0bd82ebc1095a90adcbcbc509b569621cbfe2 /server/sonar-ce-task-projectanalysis/src/main
parentd916489b37b0473728cf1f8ef6eeac4ff0307bd9 (diff)
downloadsonarqube-46543413d0cc6188a95260ec9a1c0d9b5da26e82.tar.gz
sonarqube-46543413d0cc6188a95260ec9a1c0d9b5da26e82.zip
Revert "SONAR-16370 compute issue hashes when processing scanner report"
This reverts commit 6e7de02b0cf93c482d8b640b4309814efc7b4de0.
Diffstat (limited to 'server/sonar-ce-task-projectanalysis/src/main')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java40
1 files changed, 3 insertions, 37 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java
index 0f6ae1f28e5..988c778cce7 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactory.java
@@ -25,9 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.regex.Pattern;
import javax.annotation.Nullable;
-import org.apache.commons.codec.digest.DigestUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
@@ -39,7 +37,6 @@ import org.sonar.ce.task.projectanalysis.issue.commonrule.CommonRuleEngine;
import org.sonar.ce.task.projectanalysis.issue.filter.IssueFilter;
import org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRulesHolder;
import org.sonar.ce.task.projectanalysis.source.SourceLinesHashRepository;
-import org.sonar.ce.task.projectanalysis.source.SourceLinesRepository;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.tracking.Input;
import org.sonar.core.issue.tracking.LazyInput;
@@ -57,24 +54,21 @@ import static org.sonar.api.issue.Issue.STATUS_OPEN;
import static org.sonar.api.issue.Issue.STATUS_TO_REVIEW;
public class TrackerRawInputFactory {
- private static final Pattern MATCH_ALL_WHITESPACES = Pattern.compile("\\s");
private static final long DEFAULT_EXTERNAL_ISSUE_EFFORT = 0L;
private final TreeRootHolder treeRootHolder;
private final BatchReportReader reportReader;
private final CommonRuleEngine commonRuleEngine;
private final IssueFilter issueFilter;
private final SourceLinesHashRepository sourceLinesHash;
- private final SourceLinesRepository sourceLinesRepository;
private final RuleRepository ruleRepository;
private final ActiveRulesHolder activeRulesHolder;
- public TrackerRawInputFactory(TreeRootHolder treeRootHolder, BatchReportReader reportReader, SourceLinesHashRepository sourceLinesHash,
- SourceLinesRepository sourceLinesRepository, CommonRuleEngine commonRuleEngine, IssueFilter issueFilter, RuleRepository ruleRepository,
+ public TrackerRawInputFactory(TreeRootHolder treeRootHolder, BatchReportReader reportReader,
+ SourceLinesHashRepository sourceLinesHash, CommonRuleEngine commonRuleEngine, IssueFilter issueFilter, RuleRepository ruleRepository,
ActiveRulesHolder activeRulesHolder) {
this.treeRootHolder = treeRootHolder;
this.reportReader = reportReader;
this.sourceLinesHash = sourceLinesHash;
- this.sourceLinesRepository = sourceLinesRepository;
this.commonRuleEngine = commonRuleEngine;
this.issueFilter = issueFilter;
this.ruleRepository = ruleRepository;
@@ -191,9 +185,7 @@ public class TrackerRawInputFactory {
}
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder();
if (reportIssue.hasTextRange()) {
- DbCommons.TextRange.Builder textRange = convertTextRange(reportIssue.getTextRange());
- dbLocationsBuilder.setTextRange(textRange);
- dbLocationsBuilder.setChecksum(calculateLocationHash(textRange));
+ dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange()));
}
for (ScannerReport.Flow flow : reportIssue.getFlowList()) {
if (flow.getLocationCount() > 0) {
@@ -302,36 +294,10 @@ public class TrackerRawInputFactory {
ScannerReport.TextRange sourceRange = source.getTextRange();
DbCommons.TextRange.Builder targetRange = convertTextRange(sourceRange);
target.setTextRange(targetRange);
- target.setChecksum(calculateLocationHash(targetRange));
}
return Optional.of(target.build());
}
- private String calculateLocationHash(DbCommons.TextRange.Builder textRange) {
- try (CloseableIterator<String> linesIterator = sourceLinesRepository.readLines(component)) {
- StringBuilder toHash = new StringBuilder();
- int lineNo = 1;
- while (linesIterator.hasNext()) {
- String line = linesIterator.next();
- if (lineNo == textRange.getStartLine() && lineNo == textRange.getEndLine()) {
- toHash.append(line, textRange.getStartOffset(), textRange.getEndOffset());
- } else if (lineNo == textRange.getStartLine()) {
- toHash.append(line, textRange.getStartOffset(), line.length());
- } else if (lineNo > textRange.getStartLine() && lineNo < textRange.getEndLine()) {
- toHash.append(line);
- } else if (lineNo == textRange.getEndLine()) {
- toHash.append(line, 0, textRange.getEndOffset());
- } else if (lineNo > textRange.getEndLine()) {
- break;
- }
- lineNo++;
- }
- String issueContentWithoutWhitespaces = MATCH_ALL_WHITESPACES.matcher(toHash.toString()).replaceAll("");
- return DigestUtils.md5Hex(issueContentWithoutWhitespaces);
- }
-
- }
-
private DbCommons.TextRange.Builder convertTextRange(ScannerReport.TextRange sourceRange) {
DbCommons.TextRange.Builder targetRange = DbCommons.TextRange.newBuilder();
targetRange.setStartLine(sourceRange.getStartLine());