diff options
3 files changed, 106 insertions, 47 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStep.java index 0d61acee1e2..d4b29f1c99b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStep.java @@ -37,8 +37,10 @@ import org.sonar.db.protobuf.DbFileSources; import org.sonar.db.source.FileSourceDto; import org.sonar.db.source.FileSourceDto.Type; import org.sonar.scanner.protocol.output.ScannerReport; +import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder; import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReader; 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.CrawlerDepthLimit; import org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler; import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder; @@ -69,9 +71,10 @@ public class PersistFileSourcesStep implements ComputationStep { private final SourceLinesRepository sourceLinesRepository; private final ScmInfoRepository scmInfoRepository; private final DuplicationRepository duplicationRepository; + private final AnalysisMetadataHolder analysisMetadataHolder; public PersistFileSourcesStep(DbClient dbClient, System2 system2, TreeRootHolder treeRootHolder, BatchReportReader reportReader, SourceLinesRepository sourceLinesRepository, - ScmInfoRepository scmInfoRepository, DuplicationRepository duplicationRepository) { + ScmInfoRepository scmInfoRepository, DuplicationRepository duplicationRepository, AnalysisMetadataHolder analysisMetadataHolder) { this.dbClient = dbClient; this.system2 = system2; this.treeRootHolder = treeRootHolder; @@ -79,6 +82,7 @@ public class PersistFileSourcesStep implements ComputationStep { this.sourceLinesRepository = sourceLinesRepository; this.scmInfoRepository = scmInfoRepository; this.duplicationRepository = duplicationRepository; + this.analysisMetadataHolder = analysisMetadataHolder; } @Override @@ -114,6 +118,10 @@ public class PersistFileSourcesStep implements ComputationStep { @Override public void visitFile(Component file) { + if (analysisMetadataHolder.isIncrementalAnalysis() && file.getStatus() == Status.SAME) { + return; + } + CloseableIterator<String> linesIterator = sourceLinesRepository.readLines(file); LineReaders lineReaders = new LineReaders(reportReader, scmInfoRepository, duplicationRepository, file); try { @@ -170,7 +178,7 @@ public class PersistFileSourcesStep implements ComputationStep { } } } - + @CheckForNull private String computeRevision(@Nullable Changeset latestChange) { if (latestChange == null) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java index 4c70bbdbbd9..a26c116bbfd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java @@ -19,7 +19,13 @@ */ package org.sonar.server.computation.task.projectanalysis.step; +import static com.google.common.collect.Lists.newArrayList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.util.Arrays; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -34,8 +40,10 @@ import org.sonar.db.source.FileSourceDto.Type; import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType; import org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType; +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.Component; +import org.sonar.server.computation.task.projectanalysis.component.Component.Status; import org.sonar.server.computation.task.projectanalysis.component.FileAttributes; import org.sonar.server.computation.task.projectanalysis.component.ReportComponent; import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; @@ -49,17 +57,14 @@ import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepositoryRu import org.sonar.server.computation.task.projectanalysis.source.SourceLinesRepositoryRule; import org.sonar.server.computation.task.step.ComputationStep; -import static com.google.common.collect.Lists.newArrayList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class PersistFileSourcesStepTest extends BaseStepTest { - private static final int FILE_REF = 3; + private static final int FILE1_REF = 3; + private static final int FILE2_REF = 4; private static final String PROJECT_UUID = "PROJECT"; private static final String PROJECT_KEY = "PROJECT_KEY"; - private static final String FILE_UUID = "FILE"; + private static final String FILE1_UUID = "FILE1"; + private static final String FILE2_UUID = "FILE2"; private static final long NOW = 123456789L; private System2 system2 = mock(System2.class); @@ -79,6 +84,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest { public SourceLinesRepositoryRule fileSourceRepository = new SourceLinesRepositoryRule(); @Rule public DuplicationRepositoryRule duplicationRepository = DuplicationRepositoryRule.create(treeRootHolder); + @Rule + public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule().setIncrementalAnalysis(false); private DbClient dbClient = dbTester.getDbClient(); private DbSession session = dbTester.getSession(); @@ -88,7 +95,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest { @Before public void setup() { when(system2.now()).thenReturn(NOW); - underTest = new PersistFileSourcesStep(dbClient, system2, treeRootHolder, reportReader, fileSourceRepository, scmInfoRepository, duplicationRepository); + underTest = new PersistFileSourcesStep(dbClient, system2, treeRootHolder, reportReader, fileSourceRepository, scmInfoRepository, + duplicationRepository, analysisMetadataHolder); } @Override @@ -103,9 +111,9 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getProjectUuid()).isEqualTo(PROJECT_UUID); - assertThat(fileSourceDto.getFileUuid()).isEqualTo(FILE_UUID); + assertThat(fileSourceDto.getFileUuid()).isEqualTo(FILE1_UUID); assertThat(fileSourceDto.getBinaryData()).isNotEmpty(); assertThat(fileSourceDto.getDataHash()).isNotEmpty(); assertThat(fileSourceDto.getLineHashes()).isNotEmpty(); @@ -121,13 +129,24 @@ public class PersistFileSourcesStepTest extends BaseStepTest { } @Test + public void dont_persist_unchanged_sources_if_incremental() { + analysisMetadataHolder.setIncrementalAnalysis(true); + initReportWithUnchangedFile(2); + + underTest.execute(); + + assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); + + } + + @Test public void persist_source_hashes() { initBasicReport(2); underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, "FILE"); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getLineHashes()).isEqualTo("137f72c3708c6bd0de00a0e5a69c699b\ne6251bcf1a7dc3ba5e7933e325bbe605"); assertThat(fileSourceDto.getSrcHash()).isEqualTo("ee5a58024a155466b43bc559d953e018"); } @@ -136,7 +155,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { public void persist_coverage() { initBasicReport(1); - reportReader.putCoverage(FILE_REF, newArrayList(ScannerReport.LineCoverage.newBuilder() + reportReader.putCoverage(FILE1_REF, newArrayList(ScannerReport.LineCoverage.newBuilder() .setLine(1) .setConditions(10) .setHits(true) @@ -146,7 +165,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); DbFileSources.Data data = fileSourceDto.getSourceData(); assertThat(data.getLinesList()).hasSize(1); @@ -159,7 +178,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { @Test public void persist_scm() { initBasicReport(1); - scmInfoRepository.setScmInfo(FILE_REF, Changeset.newChangesetBuilder() + scmInfoRepository.setScmInfo(FILE1_REF, Changeset.newChangesetBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") @@ -168,7 +187,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getRevision()).isEqualTo("rev-1"); @@ -185,7 +204,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { public void persist_highlighting() { initBasicReport(1); - reportReader.putSyntaxHighlighting(FILE_REF, newArrayList(ScannerReport.SyntaxHighlightingRule.newBuilder() + reportReader.putSyntaxHighlighting(FILE1_REF, newArrayList(ScannerReport.SyntaxHighlightingRule.newBuilder() .setRange(ScannerReport.TextRange.newBuilder() .setStartLine(1).setEndLine(1) .setStartOffset(2).setEndOffset(4) @@ -196,7 +215,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); DbFileSources.Data data = fileSourceDto.getSourceData(); assertThat(data.getLinesList()).hasSize(1); @@ -208,7 +227,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { public void persist_symbols() { initBasicReport(3); - reportReader.putSymbols(FILE_REF, newArrayList( + reportReader.putSymbols(FILE1_REF, newArrayList( ScannerReport.Symbol.newBuilder() .setDeclaration(ScannerReport.TextRange.newBuilder() .setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(4) @@ -221,7 +240,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); DbFileSources.Data data = fileSourceDto.getSourceData(); assertThat(data.getLinesList()).hasSize(3); @@ -236,13 +255,13 @@ public class PersistFileSourcesStepTest extends BaseStepTest { initBasicReport(1); duplicationRepository.add( - FILE_REF, + FILE1_REF, new Duplication(new TextBlock(1, 2), Arrays.<Duplicate>asList(new InnerDuplicate(new TextBlock(3, 4))))); underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); DbFileSources.Data data = fileSourceDto.getSourceData(); assertThat(data.getLinesList()).hasSize(1); @@ -253,7 +272,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { @Test public void save_revision() { initBasicReport(1); - scmInfoRepository.setScmInfo(FILE_REF, Changeset.newChangesetBuilder() + scmInfoRepository.setScmInfo(FILE1_REF, Changeset.newChangesetBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") @@ -261,7 +280,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getRevision()).isEqualTo("rev-1"); } @@ -271,7 +290,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getRevision()).isNull(); } @@ -285,7 +304,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { dbClient.fileSourceDao().insert(dbTester.getSession(), new FileSourceDto() .setProjectUuid(PROJECT_UUID) - .setFileUuid(FILE_UUID) + .setFileUuid(FILE1_UUID) .setSrcHash(srcHash) .setLineHashes(lineHashes) .setDataHash(dataHash) @@ -305,7 +324,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getSrcHash()).isEqualTo(srcHash); assertThat(fileSourceDto.getLineHashes()).isEqualTo(lineHashes); assertThat(fileSourceDto.getDataHash()).isEqualTo(dataHash); @@ -319,7 +338,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { long past = 150000L; dbClient.fileSourceDao().insert(dbTester.getSession(), new FileSourceDto() .setProjectUuid(PROJECT_UUID) - .setFileUuid(FILE_UUID) + .setFileUuid(FILE1_UUID) .setDataType(Type.SOURCE) .setSrcHash("5b4bd9815cdb17b8ceae19eb1810c34c") .setLineHashes("6438c669e0d0de98e6929c2cc0fac474\n") @@ -337,7 +356,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { initBasicReport(1); - scmInfoRepository.setScmInfo(FILE_REF, Changeset.newChangesetBuilder() + scmInfoRepository.setScmInfo(FILE1_REF, Changeset.newChangesetBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") @@ -346,7 +365,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getCreatedAt()).isEqualTo(past); assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(NOW); assertThat(fileSourceDto.getRevision()).isEqualTo("rev-1"); @@ -358,7 +377,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { long past = 150000L; dbClient.fileSourceDao().insert(dbTester.getSession(), new FileSourceDto() .setProjectUuid(PROJECT_UUID) - .setFileUuid(FILE_UUID) + .setFileUuid(FILE1_UUID) .setDataType(Type.SOURCE) // Source hash is missing, update will be made .setLineHashes("137f72c3708c6bd0de00a0e5a69c699b") @@ -378,7 +397,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getCreatedAt()).isEqualTo(past); assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(NOW); assertThat(fileSourceDto.getSrcHash()).isEqualTo("137f72c3708c6bd0de00a0e5a69c699b"); @@ -390,7 +409,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { long past = 150000L; dbClient.fileSourceDao().insert(dbTester.getSession(), new FileSourceDto() .setProjectUuid(PROJECT_UUID) - .setFileUuid(FILE_UUID) + .setFileUuid(FILE1_UUID) .setDataType(Type.SOURCE) .setSrcHash("137f72c3708c6bd0de00a0e5a69c699b") .setLineHashes("137f72c3708c6bd0de00a0e5a69c699b") @@ -406,7 +425,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { .setUpdatedAt(past)); dbTester.getSession().commit(); - scmInfoRepository.setScmInfo(FILE_REF, Changeset.newChangesetBuilder() + scmInfoRepository.setScmInfo(FILE1_REF, Changeset.newChangesetBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") @@ -417,7 +436,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getCreatedAt()).isEqualTo(past); assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(NOW); assertThat(fileSourceDto.getRevision()).isEqualTo("rev-1"); @@ -429,7 +448,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { long past = 150000L; dbClient.fileSourceDao().insert(dbTester.getSession(), new FileSourceDto() .setProjectUuid(PROJECT_UUID) - .setFileUuid(FILE_UUID) + .setFileUuid(FILE1_UUID) .setDataType(Type.SOURCE) .setSrcHash("137f72c3708c6bd0de00a0e5a69c699b") .setLineHashes("137f72c3708c6bd0de00a0e5a69c699b") @@ -450,16 +469,52 @@ public class PersistFileSourcesStepTest extends BaseStepTest { underTest.execute(); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); - FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); + FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getCreatedAt()).isEqualTo(past); assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(NOW); assertThat(fileSourceDto.getRevision()).isNull(); } + private void initReportWithUnchangedFile(int numberOfLines) { + treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren( + ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE").setKey("MODULE_KEY").addChildren( + ReportComponent.builder(Component.Type.FILE, FILE1_REF).setUuid(FILE1_UUID).setKey("MODULE_KEY:src/Foo.java") + .setFileAttributes(new FileAttributes(false, null, numberOfLines)).setStatus(Status.CHANGED).build()) + .build(), + ReportComponent.builder(Component.Type.FILE, FILE2_REF).setUuid(FILE2_UUID).setKey("MODULE_KEY:src/Foo2.java") + .setStatus(Status.SAME).build()) + .build()); + + reportReader.putComponent(ScannerReport.Component.newBuilder() + .setRef(1) + .setType(ComponentType.PROJECT) + .addChildRef(2) + .build()); + reportReader.putComponent(ScannerReport.Component.newBuilder() + .setRef(2) + .setType(ComponentType.MODULE) + .addChildRef(FILE1_REF) + .build()); + reportReader.putComponent(ScannerReport.Component.newBuilder() + .setRef(FILE1_REF) + .setType(ComponentType.FILE) + .setLines(numberOfLines) + .build()); + reportReader.putComponent(ScannerReport.Component.newBuilder() + .setRef(FILE2_REF) + .setType(ComponentType.FILE) + .setLines(numberOfLines) + .build()); + + for (int i = 1; i <= numberOfLines; i++) { + fileSourceRepository.addLine(FILE1_REF, "line" + i); + } + } + private void initBasicReport(int numberOfLines) { treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren( ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE").setKey("MODULE_KEY").addChildren( - ReportComponent.builder(Component.Type.FILE, FILE_REF).setUuid(FILE_UUID).setKey("MODULE_KEY:src/Foo.java") + ReportComponent.builder(Component.Type.FILE, FILE1_REF).setUuid(FILE1_UUID).setKey("MODULE_KEY:src/Foo.java") .setFileAttributes(new FileAttributes(false, null, numberOfLines)).build()) .build()) .build()); @@ -472,16 +527,16 @@ public class PersistFileSourcesStepTest extends BaseStepTest { reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(ComponentType.MODULE) - .addChildRef(FILE_REF) + .addChildRef(FILE1_REF) .build()); reportReader.putComponent(ScannerReport.Component.newBuilder() - .setRef(FILE_REF) + .setRef(FILE1_REF) .setType(ComponentType.FILE) .setLines(numberOfLines) .build()); for (int i = 1; i <= numberOfLines; i++) { - fileSourceRepository.addLine(FILE_REF, "line" + i); + fileSourceRepository.addLine(FILE1_REF, "line" + i); } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java index 777af5ef52b..8d3f530c25f 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java @@ -103,11 +103,7 @@ public class InputComponentStoreTest { static class InputComponentStoreTester extends InputComponentStore { InputComponentStoreTester() throws IOException { -<<<<<<< HEAD - super(TestInputFileBuilder.newDefaultInputModule("root", temp.newFolder())); -======= - super(new PathResolver(), TestInputFileBuilder.newDefaultInputModule("root", temp.newFolder()), mock(AnalysisMode.class)); ->>>>>>> SONAR-9607 Do not copy unchanged source files in scanner report + super(TestInputFileBuilder.newDefaultInputModule("root", temp.newFolder()), mock(AnalysisMode.class)); } InputFile addFile(String moduleKey, String relpath, String language) { |