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();
}
}
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();
}
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();
}
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));
}
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();
}
Aggregations