use of org.sonar.scanner.scan.branch.BranchConfiguration in project sonarqube by SonarSource.
the class SpringProjectScanContainer method doAfterStart.
@Override
protected void doAfterStart() {
getComponentByType(ProjectLock.class).tryLock();
GlobalAnalysisMode analysisMode = getComponentByType(GlobalAnalysisMode.class);
InputModuleHierarchy tree = getComponentByType(InputModuleHierarchy.class);
ScanProperties properties = getComponentByType(ScanProperties.class);
properties.validate();
properties.get("sonar.branch").ifPresent(deprecatedBranch -> {
throw MessageException.of("The 'sonar.branch' parameter is no longer supported. You should stop using it. " + "Branch analysis is available in Developer Edition and above. See https://redirect.sonarsource.com/editions/developer.html for more information.");
});
BranchConfiguration branchConfig = getComponentByType(BranchConfiguration.class);
if (branchConfig.branchType() == BranchType.PULL_REQUEST) {
LOG.info("Pull request {} for merge into {} from {}", branchConfig.pullRequestKey(), pullRequestBaseToDisplayName(branchConfig.targetBranchName()), branchConfig.branchName());
} else if (branchConfig.branchName() != null) {
LOG.info("Branch name: {}", branchConfig.branchName());
}
getComponentByType(ProjectFileIndexer.class).index();
// Log detected languages and their profiles after FS is indexed and languages detected
getComponentByType(QProfileVerifier.class).execute();
scanRecursively(tree, tree.root());
LOG.info("------------- Run sensors on project");
getComponentByType(ProjectSensorsExecutor.class).execute();
getComponentByType(ScmPublisher.class).publish();
getComponentByType(CpdExecutor.class).execute();
getComponentByType(ReportPublisher.class).execute();
if (properties.shouldWaitForQualityGate()) {
LOG.info("------------- Check Quality Gate status");
getComponentByType(QualityGateCheck.class).await();
}
getComponentByType(PostJobsExecutor.class).execute();
if (analysisMode.isMediumTest()) {
getComponentByType(AnalysisObservers.class).notifyEndOfScanTask();
}
}
use of org.sonar.scanner.scan.branch.BranchConfiguration in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method prepare.
@Before
public void prepare() throws Exception {
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
when(metricFinder.<Integer>findByKey(CoreMetrics.LINES_TO_COVER_KEY)).thenReturn(CoreMetrics.LINES_TO_COVER);
settings = new MapSettings();
moduleIssues = mock(IssuePublisher.class);
reportPublisher = mock(ReportPublisher.class);
final File reportDir = temp.newFolder();
reportWriter = new ScannerReportWriter(reportDir);
reportReader = new ScannerReportReader(reportDir);
when(reportPublisher.getWriter()).thenReturn(reportWriter);
when(reportPublisher.getReader()).thenReturn(reportReader);
branchConfiguration = mock(BranchConfiguration.class);
underTest = new DefaultSensorStorage(metricFinder, moduleIssues, settings.asConfig(), reportPublisher, mock(SonarCpdBlockIndex.class), contextPropertiesCache, new ScannerMetrics(), branchConfiguration);
project = new DefaultInputProject(ProjectDefinition.create().setKey("foo").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder()));
}
use of org.sonar.scanner.scan.branch.BranchConfiguration in project sonarqube by SonarSource.
the class ModuleSensorContextTest method prepare.
@Before
public void prepare() throws Exception {
activeRules = new ActiveRulesBuilder().build();
fs = new DefaultFileSystem(temp.newFolder().toPath());
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
settings = new MapSettings();
sensorStorage = mock(SensorStorage.class);
branchConfiguration = mock(BranchConfiguration.class);
runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY);
}
use of org.sonar.scanner.scan.branch.BranchConfiguration in project sonarqube by SonarSource.
the class ComponentsPublisherTest method setUp.
@Before
public void setUp() throws IOException {
branchConfiguration = mock(BranchConfiguration.class);
outputDir = temp.newFolder();
writer = new ScannerReportWriter(outputDir);
}
use of org.sonar.scanner.scan.branch.BranchConfiguration in project sonarqube by SonarSource.
the class DefaultActiveRulesLoaderTest method setUp.
@Before
public void setUp() {
wsClient = mock(DefaultScannerWsClient.class);
BranchConfiguration branchConfig = mock(BranchConfiguration.class);
when(branchConfig.isPullRequest()).thenReturn(false);
loader = new DefaultActiveRulesLoader(wsClient);
}
Aggregations