aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-09-15 14:47:23 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-09-18 11:01:56 +0200
commitb49d5fffa424e694658f19cff43379c4c9ca31b4 (patch)
tree86eb7a231d20dd6241a1bed917367d0d7e9e4b87 /server
parent4f3018eb093f9c2d5406df7674eb0e9a7b50e44c (diff)
downloadsonarqube-b49d5fffa424e694658f19cff43379c4c9ca31b4.tar.gz
sonarqube-b49d5fffa424e694658f19cff43379c4c9ca31b4.zip
SONAR-9621 Always load cpd blocks from report when mode != incremental
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStep.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java7
2 files changed, 5 insertions, 4 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStep.java
index fa9518c73a4..8d57e9bf5cd 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStep.java
@@ -95,7 +95,7 @@ public class PersistCrossProjectDuplicationIndexStep implements ComputationStep
}
private void visitComponent(Component component) {
- if (component.getStatus() == Status.SAME) {
+ if (analysisMetadataHolder.isIncrementalAnalysis() && component.getStatus() == Status.SAME) {
readFromDb(component);
} else {
readFromReport(component);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java
index a10bc797231..bbb35da5f17 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistCrossProjectDuplicationIndexStepTest.java
@@ -37,10 +37,10 @@ import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.server.computation.task.projectanalysis.analysis.Analysis;
import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
-import org.sonar.server.computation.task.projectanalysis.component.Component.Status;
import org.sonar.server.computation.task.projectanalysis.component.Component;
+import org.sonar.server.computation.task.projectanalysis.component.Component.Status;
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.duplication.CrossProjectDuplicationStatusHolder;
import org.sonar.server.computation.task.step.ComputationStep;
@@ -95,12 +95,14 @@ public class PersistCrossProjectDuplicationIndexStepTest {
when(baseAnalysis.getUuid()).thenReturn(BASE_ANALYSIS_UUID);
analysisMetadataHolder.setUuid(ANALYSIS_UUID);
analysisMetadataHolder.setBaseAnalysis(baseAnalysis);
+ analysisMetadataHolder.setIncrementalAnalysis(false);
underTest = new PersistCrossProjectDuplicationIndexStep(crossProjectDuplicationStatusHolder, dbClient, treeRootHolder, analysisMetadataHolder, reportReader);
}
@Test
public void copy_base_analysis_in_incremental_mode() {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true);
+ analysisMetadataHolder.setIncrementalAnalysis(true);
DuplicationUnitDto dup = new DuplicationUnitDto();
dup.setAnalysisUuid(BASE_ANALYSIS_UUID);
dup.setComponentUuid(FILE_2_UUID);
@@ -124,7 +126,6 @@ public class PersistCrossProjectDuplicationIndexStepTest {
assertThat(dto.get("INDEX_IN_FILE")).isEqualTo(0L);
assertThat(dto.get("COMPONENT_UUID")).isEqualTo(FILE_2.getUuid());
assertThat(dto.get("ANALYSIS_UUID")).isEqualTo(ANALYSIS_UUID);
-
}
@Test