Search in sources :

Example 1 with DefaultAnalysisMode

use of org.sonar.scanner.analysis.DefaultAnalysisMode in project sonarqube by SonarSource.

the class ProjectScanContainer method doAfterStart.

@Override
protected void doAfterStart() {
    DefaultAnalysisMode analysisMode = getComponentByType(DefaultAnalysisMode.class);
    InputModuleHierarchy tree = getComponentByType(InputModuleHierarchy.class);
    analysisMode.printMode();
    LOG.info("Project key: {}", tree.root().key());
    String organization = props.property("sonar.organization");
    if (StringUtils.isNotEmpty(organization)) {
        LOG.info("Organization key: {}", organization);
    }
    String branch = tree.root().definition().getBranch();
    if (branch != null) {
        LOG.info("Branch key: {}", branch);
    }
    LOG.debug("Start recursive analysis of project modules");
    scanRecursively(tree, tree.root());
    if (analysisMode.isMediumTest()) {
        getComponentByType(ScanTaskObservers.class).notifyEndOfScanTask();
    }
}
Also used : InputModuleHierarchy(org.sonar.api.batch.fs.internal.InputModuleHierarchy) ScanTaskObservers(org.sonar.scanner.mediumtest.ScanTaskObservers) DefaultAnalysisMode(org.sonar.scanner.analysis.DefaultAnalysisMode)

Example 2 with DefaultAnalysisMode

use of org.sonar.scanner.analysis.DefaultAnalysisMode in project sonarqube by SonarSource.

the class DefaultAnalysisModeTest method scan_all.

@Test
public void scan_all() {
    Map<String, String> props = new HashMap<>();
    props.put(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ISSUES);
    GlobalProperties globalProps = new GlobalProperties(props);
    AnalysisProperties analysisProps = new AnalysisProperties(new HashMap<String, String>());
    DefaultAnalysisMode mode = new DefaultAnalysisMode(globalProps, analysisProps);
    assertThat(mode.scanAllFiles()).isFalse();
    props.put("sonar.scanAllFiles", "true");
    analysisProps = new AnalysisProperties(props);
    mode = new DefaultAnalysisMode(globalProps, analysisProps);
    assertThat(mode.scanAllFiles()).isTrue();
    props.put(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PUBLISH);
    analysisProps = new AnalysisProperties(props);
    mode = new DefaultAnalysisMode(globalProps, analysisProps);
    assertThat(mode.scanAllFiles()).isTrue();
}
Also used : GlobalProperties(org.sonar.scanner.bootstrap.GlobalProperties) HashMap(java.util.HashMap) AnalysisProperties(org.sonar.scanner.analysis.AnalysisProperties) DefaultAnalysisMode(org.sonar.scanner.analysis.DefaultAnalysisMode) Test(org.junit.Test)

Example 3 with DefaultAnalysisMode

use of org.sonar.scanner.analysis.DefaultAnalysisMode in project sonarqube by SonarSource.

the class DefaultAnalysisModeTest method support_issues_mode.

@Test
public void support_issues_mode() {
    DefaultAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_ISSUES);
    assertThat(mode.isIssues()).isTrue();
    assertThat(mode.scanAllFiles()).isFalse();
}
Also used : DefaultAnalysisMode(org.sonar.scanner.analysis.DefaultAnalysisMode) Test(org.junit.Test)

Example 4 with DefaultAnalysisMode

use of org.sonar.scanner.analysis.DefaultAnalysisMode in project sonarqube by SonarSource.

the class DefaultAnalysisModeTest method createMode.

private static DefaultAnalysisMode createMode(@Nullable String bootstrapMode, @Nullable String analysisMode) {
    Map<String, String> bootstrapMap = new HashMap<>();
    Map<String, String> analysisMap = new HashMap<>();
    if (bootstrapMode != null) {
        bootstrapMap.put(CoreProperties.ANALYSIS_MODE, bootstrapMode);
    }
    if (analysisMode != null) {
        analysisMap.put(CoreProperties.ANALYSIS_MODE, analysisMode);
    }
    return new DefaultAnalysisMode(new GlobalProperties(bootstrapMap), new AnalysisProperties(analysisMap));
}
Also used : GlobalProperties(org.sonar.scanner.bootstrap.GlobalProperties) HashMap(java.util.HashMap) AnalysisProperties(org.sonar.scanner.analysis.AnalysisProperties) DefaultAnalysisMode(org.sonar.scanner.analysis.DefaultAnalysisMode)

Example 5 with DefaultAnalysisMode

use of org.sonar.scanner.analysis.DefaultAnalysisMode in project sonarqube by SonarSource.

the class DefaultAnalysisModeTest method regular_analysis_by_default.

@Test
public void regular_analysis_by_default() {
    DefaultAnalysisMode mode = createMode(null, null);
    assertThat(mode.isPreview()).isFalse();
    assertThat(mode.isPublish()).isTrue();
}
Also used : DefaultAnalysisMode(org.sonar.scanner.analysis.DefaultAnalysisMode) Test(org.junit.Test)

Aggregations

DefaultAnalysisMode (org.sonar.scanner.analysis.DefaultAnalysisMode)8 Test (org.junit.Test)6 HashMap (java.util.HashMap)2 AnalysisProperties (org.sonar.scanner.analysis.AnalysisProperties)2 GlobalProperties (org.sonar.scanner.bootstrap.GlobalProperties)2 InputModuleHierarchy (org.sonar.api.batch.fs.internal.InputModuleHierarchy)1 ScanTaskObservers (org.sonar.scanner.mediumtest.ScanTaskObservers)1