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 {
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();
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
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);
}
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
}
private DefaultAnalysisMode createmode(AnalysisProperties analysisProps) {
- return new DefaultAnalysisMode(analysisProps, branchConfig, globalMode);
+ return new DefaultAnalysisMode(analysisProps, globalMode);
}
}