]> source.dussan.org Git - sonarqube.git/commitdiff
Analyze all files even in short branches
authorJanos Gyerik <janos.gyerik@sonarsource.com>
Mon, 9 Oct 2017 13:53:10 +0000 (15:53 +0200)
committerJanos Gyerik <janos.gyerik@sonarsource.com>
Thu, 12 Oct 2017 07:56:30 +0000 (09:56 +0200)
sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/analysis/DefaultAnalysisModeTest.java

index 68612147d9d50e196d1e03321c3dd407946069b5..740a8c68659f9549f6e58e3560f57c396b7f26e8 100644 (file)
@@ -25,7 +25,6 @@ import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
-import org.sonar.scanner.scan.branch.BranchConfiguration;
 
 @Immutable
 public class DefaultAnalysisMode implements AnalysisMode {
@@ -34,12 +33,10 @@ public class DefaultAnalysisMode implements AnalysisMode {
 
   private final Map<String, String> analysisProps;
   private final GlobalAnalysisMode analysisMode;
-  private final BranchConfiguration branchConfig;
 
   private boolean scanAllFiles;
 
-  public DefaultAnalysisMode(AnalysisProperties props, BranchConfiguration branchConfig, GlobalAnalysisMode analysisMode) {
-    this.branchConfig = branchConfig;
+  public DefaultAnalysisMode(AnalysisProperties props, GlobalAnalysisMode analysisMode) {
     this.analysisMode = analysisMode;
     this.analysisProps = props.properties();
     load();
@@ -58,7 +55,7 @@ public class DefaultAnalysisMode implements AnalysisMode {
 
   private void load() {
     String scanAllStr = analysisProps.get(KEY_SCAN_ALL);
-    scanAllFiles = !branchConfig.isShortLivingBranch() && (!analysisMode.isIssues() || "true".equals(scanAllStr));
+    scanAllFiles = !analysisMode.isIssues() || "true".equals(scanAllStr);
   }
 
   @Override
index 9e896ecdc5668c779ec53a44215850cdb4136cc0..df003ae4e8e9ce46e085dee496e59e1130effaba 100644 (file)
@@ -25,19 +25,16 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
-import org.sonar.scanner.scan.branch.BranchConfiguration;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public class DefaultAnalysisModeTest {
-  private BranchConfiguration branchConfig;
   private GlobalAnalysisMode globalMode;
 
   @Before
   public void setUp() {
-    branchConfig = mock(BranchConfiguration.class);
     globalMode = mock(GlobalAnalysisMode.class);
   }
 
@@ -45,12 +42,11 @@ public class DefaultAnalysisModeTest {
   public ExpectedException thrown = ExpectedException.none();
 
   @Test
-  public void dont_scan_all_if_short_lived_branch() {
+  public void scan_all_even_on_short_lived_branch() {
     AnalysisProperties analysisProps = new AnalysisProperties(Collections.singletonMap("sonar.scanAllFiles", "true"));
-    when(branchConfig.isShortLivingBranch()).thenReturn(true);
     DefaultAnalysisMode mode = createmode(analysisProps);
 
-    assertThat(mode.scanAllFiles()).isFalse();
+    assertThat(mode.scanAllFiles()).isTrue();
   }
 
   @Test
@@ -90,7 +86,7 @@ public class DefaultAnalysisModeTest {
   }
 
   private DefaultAnalysisMode createmode(AnalysisProperties analysisProps) {
-    return new DefaultAnalysisMode(analysisProps, branchConfig, globalMode);
+    return new DefaultAnalysisMode(analysisProps, globalMode);
   }
 
 }