]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9701 Don't publish coverage, scm and source of unchanged files
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 6 Sep 2017 14:34:06 +0000 (16:34 +0200)
committerJanos Gyerik <janos.gyerik@sonarsource.com>
Tue, 12 Sep 2017 09:34:59 +0000 (11:34 +0200)
23 files changed:
sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/BranchConfiguration.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStore.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputComponentStoreProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/scm/ScmMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/CoveragePublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MeasuresPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/SourcePublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleIndexerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java

index b90ab462a6e8a547c0b8bbef462555653e62f48f..6e7bf1a508c4fb120b1b52678e9c8b5d85f0e834 100644 (file)
@@ -28,7 +28,6 @@ import org.sonar.api.utils.log.Loggers;
 import org.sonar.scanner.bootstrap.AbstractAnalysisMode;
 import org.sonar.scanner.bootstrap.GlobalProperties;
 import org.sonar.scanner.scan.BranchConfiguration;
-import org.sonar.scanner.scan.BranchConfiguration.BranchType;
 
 @Immutable
 public class DefaultAnalysisMode extends AbstractAnalysisMode {
@@ -50,13 +49,12 @@ public class DefaultAnalysisMode extends AbstractAnalysisMode {
     // make sure analysis is consistent with global properties
     boolean globalPreview = isIssues(globalProps);
     boolean analysisPreview = isIssues(analysisProps);
-    boolean shortLivingBranch = branchConfig.branchType() == BranchType.SHORT;
 
     if (!globalPreview && analysisPreview) {
       throw new IllegalStateException("Inconsistent properties: global properties doesn't enable issues mode while analysis properties enables it");
     }
 
-    load(globalProps, analysisProps, shortLivingBranch);
+    load(globalProps, analysisProps, branchConfig.isShortLivingBranch());
   }
 
   private void load(Map<String, String> globalProps, Map<String, String> analysisProps, boolean isShortLivingBranch) {
index 1ce8033e270d4f8cd824937ab7879d413e1252b7..af5bddfc8f5171225b5361273ab40dc861f73f95 100644 (file)
@@ -19,8 +19,9 @@
  */
 package org.sonar.scanner.cpd;
 
-import static com.google.common.collect.FluentIterable.from;
-
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -29,7 +30,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
 import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputComponent;
@@ -46,13 +46,10 @@ import org.sonar.scanner.protocol.output.ScannerReport.Duplicate;
 import org.sonar.scanner.protocol.output.ScannerReport.Duplication;
 import org.sonar.scanner.report.ReportPublisher;
 import org.sonar.scanner.scan.BranchConfiguration;
-import org.sonar.scanner.scan.BranchConfiguration.BranchType;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 import org.sonar.scanner.util.ProgressReport;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
+import static com.google.common.collect.FluentIterable.from;
 
 /**
  * Runs on the root module, at the end of the project analysis.
@@ -86,7 +83,7 @@ public class CpdExecutor {
   }
 
   public void execute() {
-    if (branchConfiguration.branchType() == BranchType.SHORT) {
+    if (branchConfiguration.isShortLivingBranch()) {
       LOG.info("Skipping CPD calculation for short living branch");
       return;
     }
index 84275b0d0e2c7011ea932655130767eb8e9ee0eb..c8dd7a3097bd01fe6cf53ed14107b6b198fedf9a 100644 (file)
@@ -45,7 +45,6 @@ import org.sonar.scanner.protocol.output.ScannerReport.Issue;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.scan.BranchConfiguration;
-import org.sonar.scanner.scan.BranchConfiguration.BranchType;
 
 /**
  * Adds components and analysis metadata to output report
@@ -65,10 +64,6 @@ public class ComponentsPublisher implements ReportPublisherStep {
     this.branchConfiguration = branchConfiguration;
   }
 
-  private boolean isShortLivingBranch() {
-    return branchConfiguration.branchType() == BranchType.SHORT;
-  }
-
   @Override
   public void publish(ScannerReportWriter writer) {
     this.reader = new ScannerReportReader(writer.getFileStructure().root());
@@ -175,7 +170,7 @@ public class ComponentsPublisher implements ReportPublisherStep {
   }
 
   private boolean shouldSkipComponent(DefaultInputComponent component, Collection<InputComponent> children) {
-    if (component instanceof InputModule && children.isEmpty() && isShortLivingBranch()) {
+    if (component instanceof InputModule && children.isEmpty() && branchConfiguration.isShortLivingBranch()) {
       // no children on a module in short branch analysis -> skip it (except root)
       return !moduleHierarchy.isRoot((InputModule) component);
     } else if (component instanceof InputDir && children.isEmpty()) {
@@ -188,7 +183,7 @@ public class ComponentsPublisher implements ReportPublisherStep {
     } else if (component instanceof DefaultInputFile) {
       // skip files not marked for publishing
       DefaultInputFile inputFile = (DefaultInputFile) component;
-      return !inputFile.isPublished() || (isShortLivingBranch() && inputFile.status() == Status.SAME);
+      return !inputFile.isPublished() || (branchConfiguration.isShortLivingBranch() && inputFile.status() == Status.SAME);
     }
     return false;
   }
index f6a2626d8d379dcb732c452c9563cae42dcf6931..2a4152c617450db575681ef86f683c0802ad2b67 100644 (file)
@@ -40,6 +40,10 @@ public interface BranchConfiguration {
    */
   BranchType branchType();
 
+  default boolean isShortLivingBranch() {
+    return branchType() == BranchType.SHORT;
+  }
+
   /**
    * The name of the branch.
    */
index 060b7d2102694c296a34cc8b023a649e35dea0ff..edbb9bfd689656b07eb4b0d174e62a10fdc4314e 100644 (file)
@@ -253,12 +253,14 @@ public class ProjectScanContainer extends ComponentContainer {
   }
 
   private static String toDisplayName(BranchConfiguration.BranchType branchType) {
-    if (branchType == BranchConfiguration.BranchType.LONG) {
-      return "long living";
-    } else if (branchType == BranchConfiguration.BranchType.SHORT) {
-      return "short living";
+    switch (branchType) {
+      case LONG:
+        return "long living";
+      case SHORT:
+        return "short living";
+      default:
+        throw new UnsupportedOperationException("unknown branch type: " + branchType);
     }
-    throw new UnsupportedOperationException("unknown branch type: " + branchType);
   }
 
   private void scanRecursively(InputModuleHierarchy tree, DefaultInputModule module) {
index 0138e851c689ef00bdc828e43bdcbe8da96b802c..3c50e847b2827557eaed98a798aaf064847d56f1 100644 (file)
@@ -44,6 +44,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.FileExtensionPredicate;
 import org.sonar.api.scan.filesystem.PathResolver;
+import org.sonar.scanner.scan.BranchConfiguration;
 
 /**
  * Store of all files and dirs. This cache is shared amongst all project modules. Inclusion and
@@ -65,10 +66,12 @@ public class InputComponentStore {
   private final SetMultimap<String, InputFile> filesByExtensionCache = LinkedHashMultimap.create();
   private final InputModule root;
   private final AnalysisMode mode;
+  private final BranchConfiguration branchConfiguration;
 
-  public InputComponentStore(DefaultInputModule root, AnalysisMode mode) {
+  public InputComponentStore(DefaultInputModule root, AnalysisMode mode, BranchConfiguration branchConfiguration) {
     this.root = root;
     this.mode = mode;
+    this.branchConfiguration = branchConfiguration;
     this.put(root);
   }
 
@@ -80,7 +83,7 @@ public class InputComponentStore {
     return inputFileCache.values().stream()
       .map(f -> (DefaultInputFile) f)
       .filter(DefaultInputFile::isPublished)
-      .filter(f -> !mode.isIncremental() || f.status() != Status.SAME)::iterator;
+      .filter(f -> (!mode.isIncremental() && !branchConfiguration.isShortLivingBranch()) || f.status() != Status.SAME)::iterator;
   }
 
   public Iterable<InputFile> allFiles() {
index 2225f245207426f4679a69044154b864cb691ee0..f8e55b011de4658f7865d4a6e893a9b1f3c20aef 100644 (file)
@@ -22,13 +22,14 @@ package org.sonar.scanner.scan.filesystem;
 import org.picocontainer.injectors.ProviderAdapter;
 import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
+import org.sonar.scanner.scan.BranchConfiguration;
 
 public class InputComponentStoreProvider extends ProviderAdapter {
   private InputComponentStore store;
 
-  public InputComponentStore provide(InputModuleHierarchy hierarchy, AnalysisMode mode) {
+  public InputComponentStore provide(InputModuleHierarchy hierarchy, AnalysisMode mode, BranchConfiguration branchConfiguration) {
     if (store == null) {
-      store = new InputComponentStore(hierarchy.root(), mode);
+      store = new InputComponentStore(hierarchy.root(), mode, branchConfiguration);
     }
     return store;
   }
index 5e12f1e821af31e217872038b40b76fb6ef676c7..6fd503098b9bf8da2877bd4c00349cb53ae6820f 100644 (file)
@@ -23,6 +23,7 @@ import com.google.common.base.Preconditions;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
@@ -62,10 +63,10 @@ class DefaultBlameOutput implements BlameOutput {
   public synchronized void blameResult(InputFile file, List<BlameLine> lines) {
     Preconditions.checkNotNull(file);
     Preconditions.checkNotNull(lines);
-    Preconditions.checkArgument(allFilesToBlame.contains(file), "It was not expected to blame file %s", file.relativePath());
+    Preconditions.checkArgument(allFilesToBlame.contains(file), "It was not expected to blame file %s", file);
 
     if (lines.size() != file.lines()) {
-      LOG.debug("Ignoring blame result since provider returned {} blame lines but file {} has {} lines", lines.size(), file.relativePath(), file.lines());
+      LOG.debug("Ignoring blame result since provider returned {} blame lines but file {} has {} lines", lines.size(), file, file.lines());
       return;
     }
 
@@ -93,8 +94,8 @@ class DefaultBlameOutput implements BlameOutput {
   }
 
   private static void validateLine(BlameLine line, int lineId, InputFile file) {
-    Preconditions.checkArgument(StringUtils.isNotBlank(line.revision()), "Blame revision is blank for file %s at line %s", file.relativePath(), lineId);
-    Preconditions.checkArgument(line.date() != null, "Blame date is null for file %s at line %s", file.relativePath(), lineId);
+    Preconditions.checkArgument(StringUtils.isNotBlank(line.revision()), "Blame revision is blank for file %s at line %s", file, lineId);
+    Preconditions.checkArgument(line.date() != null, "Blame date is null for file %s at line %s", file, lineId);
   }
 
   private static void addChangeset(Builder scmBuilder, BlameLine line) {
@@ -112,7 +113,7 @@ class DefaultBlameOutput implements BlameOutput {
     if (inputString == null) {
       return "";
     }
-    return inputString.toLowerCase();
+    return inputString.toLowerCase(Locale.US);
   }
 
   public void finish(boolean success) {
@@ -120,7 +121,7 @@ class DefaultBlameOutput implements BlameOutput {
     if (success && !allFilesToBlame.isEmpty()) {
       LOG.warn("Missing blame information for the following files:");
       for (InputFile f : allFilesToBlame) {
-        LOG.warn("  * " + f.absolutePath());
+        LOG.warn("  * " + f);
       }
       LOG.warn("This may lead to missing/broken features in SonarQube");
     }
index 27c185fe545f8f01bb0242f29212e3a7e2b2fd5c..50cf4958c5f815604ca46ee72a2e1638c7b744c3 100644 (file)
@@ -37,6 +37,7 @@ import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.report.ReportPublisher;
 import org.sonar.scanner.repository.FileData;
 import org.sonar.scanner.repository.ProjectRepositories;
+import org.sonar.scanner.scan.BranchConfiguration;
 import org.sonar.scanner.scan.filesystem.DefaultModuleFileSystem;
 import org.sonar.scanner.scan.filesystem.ModuleInputComponentStore;
 
@@ -52,14 +53,16 @@ public final class ScmPublisher {
   private final ModuleInputComponentStore componentStore;
   private final DefaultModuleFileSystem fs;
   private final ScannerReportWriter writer;
+  private final BranchConfiguration branchConfiguration;
 
   public ScmPublisher(DefaultInputModule inputModule, ScmConfiguration configuration, ProjectRepositories projectRepositories,
-    ModuleInputComponentStore componentStore, DefaultModuleFileSystem fs, ReportPublisher reportPublisher) {
+    ModuleInputComponentStore componentStore, DefaultModuleFileSystem fs, ReportPublisher reportPublisher, BranchConfiguration branchConfiguration) {
     this.inputModule = inputModule;
     this.configuration = configuration;
     this.projectRepositories = projectRepositories;
     this.componentStore = componentStore;
     this.fs = fs;
+    this.branchConfiguration = branchConfiguration;
     this.writer = reportPublisher.getWriter();
   }
 
@@ -100,7 +103,7 @@ public final class ScmPublisher {
       }
       if (configuration.forceReloadAll() || f.status() != Status.SAME) {
         addIfNotEmpty(filesToBlame, f);
-      } else {
+      } else if (!branchConfiguration.isShortLivingBranch()) {
         // File status is SAME so that mean fileData exists
         FileData fileData = projectRepositories.fileData(inputModule.definition().getKeyWithBranch(), inputFile.getModuleRelativePath());
         if (StringUtils.isEmpty(fileData.revision())) {
index f6575cfea605bb96616350605ba99f411c753891..db2e7f8e014da3be20eda7235f1070f4d4ca4962 100644 (file)
@@ -20,9 +20,7 @@
 package org.sonar.scanner.sensor;
 
 import java.io.Serializable;
-
 import javax.annotation.concurrent.ThreadSafe;
-
 import org.sonar.api.SonarRuntime;
 import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.fs.FileSystem;
@@ -49,7 +47,6 @@ import org.sonar.api.config.Configuration;
 import org.sonar.api.config.Settings;
 import org.sonar.api.utils.Version;
 import org.sonar.scanner.scan.BranchConfiguration;
-import org.sonar.scanner.scan.BranchConfiguration.BranchType;
 import org.sonar.scanner.sensor.noop.NoOpNewAnalysisError;
 import org.sonar.scanner.sensor.noop.NoOpNewCoverage;
 import org.sonar.scanner.sensor.noop.NoOpNewCpdTokens;
@@ -151,7 +148,7 @@ public class DefaultSensorContext implements SensorContext {
 
   @Override
   public NewCoverage newCoverage() {
-    if (branchConfiguration.branchType() == BranchType.SHORT) {
+    if (branchConfiguration.isShortLivingBranch()) {
       return NO_OP_NEW_COVERAGE;
     }
     return new DefaultCoverage(sensorStorage);
@@ -159,7 +156,7 @@ public class DefaultSensorContext implements SensorContext {
 
   @Override
   public NewCpdTokens newCpdTokens() {
-    if (analysisMode.isIssues() || branchConfiguration.branchType() == BranchType.SHORT) {
+    if (analysisMode.isIssues() || branchConfiguration.isShortLivingBranch()) {
       return NO_OP_NEW_CPD_TOKENS;
     }
     return new DefaultCpdTokens(config, sensorStorage);
index b8bdfa48233d54fe07dd932eb09431ed86092be1..0d0ead878ab648b21e46337a12234d8d274560b6 100644 (file)
@@ -49,7 +49,6 @@ import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
 import org.sonar.scanner.report.ReportPublisher;
 import org.sonar.scanner.scan.BranchConfiguration;
-import org.sonar.scanner.scan.BranchConfiguration.BranchType;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -91,7 +90,7 @@ public class CpdExecutorTest {
 
     index = new SonarCpdBlockIndex(publisher, settings);
     DefaultInputModule inputModule = TestInputFileBuilder.newDefaultInputModule("foo", baseDir);
-    componentStore = new InputComponentStore(inputModule, mock(AnalysisMode.class));
+    componentStore = new InputComponentStore(inputModule, mock(AnalysisMode.class), mock(BranchConfiguration.class));
     executor = new CpdExecutor(settings, index, publisher, componentStore, branchConfig);
     reader = new ScannerReportReader(outputDir);
 
@@ -102,7 +101,7 @@ public class CpdExecutorTest {
 
   @Test
   public void skipIfShortBranch() {
-    when(branchConfig.branchType()).thenReturn(BranchType.SHORT);
+    when(branchConfig.isShortLivingBranch()).thenReturn(true);
     index = mock(SonarCpdBlockIndex.class);
     executor = new CpdExecutor(settings, index, publisher, componentStore, branchConfig);
 
index bf4b0f4f310c6d33c86b1bf1994a1edc6e479d67..58d9133dddc150541386aa8516f87fdd334e8216 100644 (file)
@@ -42,8 +42,10 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 public class BranchMediumTest {
 
+  private static final String PROJECT_KEY = "sample";
+  private static final String FILE_PATH = "HelloJava.xoo";
+  private static final String FILE_CONTENT = "xoooo";
   private File baseDir;
-  private final String relativePath = "HelloJava.xoo";
 
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
@@ -58,24 +60,31 @@ public class BranchMediumTest {
   @Before
   public void prepare() throws IOException {
     baseDir = temp.newFolder();
-    Path filepath = baseDir.toPath().resolve(relativePath);
-    Files.write(filepath, "xoooo".getBytes());
+    Path filepath = baseDir.toPath().resolve(FILE_PATH);
+    Files.write(filepath, FILE_CONTENT.getBytes());
 
     String md5sum = new FileMetadata()
-      .readMetadata(Files.newInputStream(filepath), StandardCharsets.UTF_8, relativePath)
+      .readMetadata(Files.newInputStream(filepath), StandardCharsets.UTF_8, FILE_PATH)
       .hash();
-    tester.addFileData("sample", relativePath, new FileData(md5sum, null));
+    tester.addFileData(PROJECT_KEY, FILE_PATH, new FileData(md5sum, "1.1"));
   }
 
   @Test
   public void should_skip_report_for_unchanged_files_in_short_branch() {
     // sanity check, normally report gets generated
     TaskResult result = getResult(tester);
-    assertThat(getResult(tester).getReportComponent(result.inputFile(relativePath).key())).isNotNull();
+    assertThat(getResult(tester).getReportComponent(result.inputFile(FILE_PATH).key())).isNotNull();
+    int fileId = 2;
+    assertThat(result.getReportReader().readChangesets(fileId)).isNotNull();
+    assertThat(result.getReportReader().hasCoverage(fileId)).isTrue();
+    assertThat(result.getReportReader().readFileSource(fileId)).isNotNull();
 
     // file is skipped for short branches (no report, no coverage, no duplications)
     TaskResult result2 = getResult(tester.setBranchType(BranchConfiguration.BranchType.SHORT));
-    assertThat(result2.getReportComponent(result2.inputFile(relativePath).key())).isNull();
+    assertThat(result2.getReportComponent(result2.inputFile(FILE_PATH).key())).isNull();
+    assertThat(result2.getReportReader().readChangesets(fileId)).isNull();
+    assertThat(result2.getReportReader().hasCoverage(fileId)).isFalse();
+    assertThat(result.getReportReader().readFileSource(fileId)).isNull();
   }
 
   @Test
@@ -100,8 +109,9 @@ public class BranchMediumTest {
       .properties(ImmutableMap.<String, String>builder()
         .put("sonar.task", "scan")
         .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
-        .put("sonar.projectKey", "sample")
+        .put("sonar.projectKey", PROJECT_KEY)
         .put("sonar.sources", ".")
+        .put("sonar.scm.provider", "xoo")
         .build())
       .execute();
   }
index fbf81aa0c7e1325f2c1164770583299e55d21bae..2fc4af185a3ab1627c511b540c4575e0a0450d9d 100644 (file)
@@ -31,7 +31,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.utils.PathUtils;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester.TaskBuilder;
@@ -180,7 +179,7 @@ public class ScmMediumTest {
     assertThat(fileWithoutBlameScm).isNull();
 
     assertThat(logTester.logs()).containsSubsequence("2 files to be analyzed", "1/2 files analyzed", MISSING_BLAME_INFORMATION_FOR_THE_FOLLOWING_FILES,
-      "  * " + PathUtils.sanitize(xooFileWithoutBlame.toPath().toString()));
+      "  * src/sample_no_blame.xoo");
   }
 
   // SONAR-6397
@@ -239,7 +238,7 @@ public class ScmMediumTest {
     // 5 .xoo files + 3 .scm files, but only 4 marked for publishing. 1 file is SAME so not included in the total
     assertThat(logTester.logs()).containsSubsequence("8 files indexed");
     assertThat(logTester.logs()).containsSubsequence("4 files to be analyzed", "3/4 files analyzed");
-    assertThat(logTester.logs()).containsSubsequence(MISSING_BLAME_INFORMATION_FOR_THE_FOLLOWING_FILES, "  * " + noBlameScmOnServer.getPath().replaceAll("\\\\", "/"));
+    assertThat(logTester.logs()).containsSubsequence(MISSING_BLAME_INFORMATION_FOR_THE_FOLLOWING_FILES, "  * src/no_blame_scm_on_server.xoo");
   }
 
   @Test
index 8d0eb0085da468674a40e421d6d3c14dd797e00e..f39cafcadb7a92953b7fd78dc11f1ec2d644018c 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.api.batch.rule.Severity;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.scanner.issue.IssueCache;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
+import org.sonar.scanner.scan.BranchConfiguration;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -54,7 +55,7 @@ public class DefaultPostJobContextTest {
   public void setUp() throws IOException {
     issueCache = mock(IssueCache.class);
     DefaultInputModule rootModule = TestInputFileBuilder.newDefaultInputModule("foo", temp.newFolder());
-    componentStore = new InputComponentStore(rootModule, mock(AnalysisMode.class));
+    componentStore = new InputComponentStore(rootModule, mock(AnalysisMode.class), mock(BranchConfiguration.class));
     settings = new MapSettings();
     analysisMode = mock(AnalysisMode.class);
     context = new DefaultPostJobContext(settings.asConfig(), settings, issueCache, componentStore, analysisMode);
index 5b0406bdfc1100809f6360debde2a09b1299a3e5..a03afd14359d91fd36118d24cb718acb9cd8b9f6 100644 (file)
@@ -313,7 +313,7 @@ public class ComponentsPublisherTest {
 
   @Test
   public void skip_unchanged_components_in_short_branches() throws IOException {
-    when(branchConfiguration.branchType()).thenReturn(BranchType.SHORT);
+    when(branchConfiguration.isShortLivingBranch()).thenReturn(true);
     ProjectAnalysisInfo projectAnalysisInfo = mock(ProjectAnalysisInfo.class);
     when(projectAnalysisInfo.analysisDate()).thenReturn(DateUtils.parseDate("2012-12-12"));
 
index 76ce5527497eef24994382f5fe63dc3dfc973d61..f2a0e614bae29ae8a2aa2d9cb70e9bdf7b3c0f71 100644 (file)
@@ -35,6 +35,7 @@ import org.sonar.core.util.CloseableIterator;
 import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
+import org.sonar.scanner.scan.BranchConfiguration;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 import org.sonar.scanner.scan.measure.MeasureCache;
 
@@ -58,7 +59,7 @@ public class CoveragePublisherTest {
     String moduleKey = "foo";
     inputFile = new TestInputFileBuilder(moduleKey, "src/Foo.php").setLines(5).build();
     DefaultInputModule rootModule = TestInputFileBuilder.newDefaultInputModule(moduleKey, temp.newFolder());
-    InputComponentStore componentCache = new InputComponentStore(rootModule, mock(AnalysisMode.class));
+    InputComponentStore componentCache = new InputComponentStore(rootModule, mock(AnalysisMode.class), mock(BranchConfiguration.class));
     componentCache.put(inputFile);
 
     measureCache = mock(MeasureCache.class);
index 3e5c7d507e56beffc3352778636f7bd5f3e806a5..31a60b633c8f95c2e3099f442d889248e6257bb4 100644 (file)
@@ -39,6 +39,7 @@ import org.sonar.scanner.deprecated.test.TestPlanBuilder;
 import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
+import org.sonar.scanner.scan.BranchConfiguration;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 import org.sonar.scanner.scan.measure.MeasureCache;
 
@@ -69,7 +70,7 @@ public class MeasuresPublisherTest {
     String moduleKey = "foo";
     inputModule = TestInputFileBuilder.newDefaultInputModule(moduleKey, temp.newFolder());
     inputFile = new TestInputFileBuilder(moduleKey, "src/Foo.php").setPublish(true).build();
-    InputComponentStore componentCache = new InputComponentStore(inputModule, mock(AnalysisMode.class));
+    InputComponentStore componentCache = new InputComponentStore(inputModule, mock(AnalysisMode.class), mock(BranchConfiguration.class));
     componentCache.put(inputFile);
     measureCache = mock(MeasureCache.class);
     when(measureCache.byComponentKey(anyString())).thenReturn(Collections.<DefaultMeasure<?>>emptyList());
index 60b51e5a8f247fd62b68c8d9160935300450552a..b859b3962e836bb7dc1d1ab415070806ade6aee7 100644 (file)
@@ -33,6 +33,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.scanner.protocol.output.ScannerReportWriter;
+import org.sonar.scanner.scan.BranchConfiguration;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -62,7 +63,7 @@ public class SourcePublisherTest {
 
     DefaultInputModule rootModule = TestInputFileBuilder.newDefaultInputModule(moduleKey, baseDir);
     analysisMode = mock(AnalysisMode.class);
-    InputComponentStore componentStore = new InputComponentStore(rootModule, analysisMode);
+    InputComponentStore componentStore = new InputComponentStore(rootModule, analysisMode, mock(BranchConfiguration.class));
     componentStore.put(inputFile);
 
     publisher = new SourcePublisher(componentStore);
index a11e500c30232ad37952bcafd12ac3d82d4bc210..e9d075d327e228fc6a9d969e82d9b7b5ac4d3c0b 100644 (file)
@@ -38,7 +38,7 @@ public class ModuleIndexerTest {
   private InputComponentStore componentStore;
 
   public void createIndexer(DefaultInputModule rootModule) {
-    componentStore = new InputComponentStore(rootModule, mock(AnalysisMode.class));
+    componentStore = new InputComponentStore(rootModule, mock(AnalysisMode.class), mock(BranchConfiguration.class));
     tree = new DefaultComponentTree();
     moduleHierarchy = mock(DefaultInputModuleHierarchy.class);
     indexer = new ModuleIndexer(tree, componentStore, moduleHierarchy);
index 8d3f530c25fccb2e9ae494ae63a720052aec5438..aacfb609f52947b73dbc977aa65b5ea93444d0ae 100644 (file)
@@ -36,6 +36,7 @@ import org.sonar.api.batch.fs.InputPath;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.scanner.scan.BranchConfiguration;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -59,7 +60,7 @@ public class InputComponentStoreTest {
     DefaultInputModule rootModule = TestInputFileBuilder.newDefaultInputModule(rootDef);
     DefaultInputModule subModule = TestInputFileBuilder.newDefaultInputModule(moduleDef);
 
-    InputComponentStore cache = new InputComponentStore(rootModule, mock(AnalysisMode.class));
+    InputComponentStore cache = new InputComponentStore(rootModule, mock(AnalysisMode.class), mock(BranchConfiguration.class));
     cache.put(subModule);
 
     DefaultInputFile fooFile = new TestInputFileBuilder(rootModuleKey, "src/main/java/Foo.java")
@@ -103,7 +104,7 @@ public class InputComponentStoreTest {
 
   static class InputComponentStoreTester extends InputComponentStore {
     InputComponentStoreTester() throws IOException {
-      super(TestInputFileBuilder.newDefaultInputModule("root", temp.newFolder()), mock(AnalysisMode.class));
+      super(TestInputFileBuilder.newDefaultInputModule("root", temp.newFolder()), mock(AnalysisMode.class), mock(BranchConfiguration.class));
     }
 
     InputFile addFile(String moduleKey, String relpath, String language) {
index 0911d7436c72d057aa81f35ca75d251b635495c8..9856377a92ce820cefa44ab0ece9dd738e4b5d59 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.api.batch.fs.InputModule;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.SensorStrategy;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.scanner.scan.BranchConfiguration;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Matchers.any;
@@ -48,7 +49,7 @@ public class ModuleInputComponentStoreTest {
   @Before
   public void setUp() throws IOException {
     DefaultInputModule root = TestInputFileBuilder.newDefaultInputModule(moduleKey, temp.newFolder());
-    componentStore = new InputComponentStore(root, mock(AnalysisMode.class));
+    componentStore = new InputComponentStore(root, mock(AnalysisMode.class), mock(BranchConfiguration.class));
   }
 
   @Test
index 148dabfdab9d3c31da6c419085d9c1acb016c3c2..4b005062ddb53eed870820a12dcd39e77be8fd8a 100644 (file)
@@ -48,6 +48,7 @@ import org.sonar.api.platform.Server;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.scanner.issue.IssueCache;
 import org.sonar.scanner.issue.tracking.TrackedIssue;
+import org.sonar.scanner.scan.BranchConfiguration;
 import org.sonar.scanner.scan.DefaultComponentTree;
 import org.sonar.scanner.scan.filesystem.InputComponentStore;
 
@@ -83,7 +84,7 @@ public class JSONReportTest {
     DefaultComponentTree inputComponentTree = new DefaultComponentTree();
     ProjectDefinition def = ProjectDefinition.create().setBaseDir(projectBaseDir).setWorkDir(temp.newFolder()).setKey("struts");
     DefaultInputModule rootModule = new DefaultInputModule(def, 1);
-    InputComponentStore inputComponentStore = new InputComponentStore(rootModule, mock(AnalysisMode.class));
+    InputComponentStore inputComponentStore = new InputComponentStore(rootModule, mock(AnalysisMode.class), mock(BranchConfiguration.class));
 
     DefaultInputModule moduleA = new DefaultInputModule(ProjectDefinition.create().setKey("struts-core").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder()));
     inputComponentTree.index(moduleA, rootModule);
index 92c62a33436afc7be6b20eab6a4ea2b7e3e40a40..aa62800ee918ab560d0096c072f56b380823c86a 100644 (file)
@@ -91,7 +91,7 @@ public class DefaultSensorContextTest {
 
   @Test
   public void shouldSkipDupsAndCoverageOnShortBranches() {
-    when(branchConfig.branchType()).thenReturn(BranchConfiguration.BranchType.SHORT);
+    when(branchConfig.isShortLivingBranch()).thenReturn(true);
     assertThat(adaptor.newCpdTokens()).isEqualTo(DefaultSensorContext.NO_OP_NEW_CPD_TOKENS);
     assertThat(adaptor.newCoverage()).isEqualTo(DefaultSensorContext.NO_OP_NEW_COVERAGE);
   }