use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class HandleUnanalyzedLanguagesStep method computeMeasures.
private void computeMeasures(Map<String, Integer> filesPerLanguage) {
Component project = treeRootHolder.getRoot();
Integer unanalyzedCFiles = filesPerLanguage.getOrDefault(C.toString(), 0);
if (unanalyzedCFiles > 0) {
measureRepository.add(project, unanalyzedCMetric, Measure.newMeasureBuilder().create(unanalyzedCFiles));
}
Integer unanalyzedCppFiles = filesPerLanguage.getOrDefault(CPP.toString(), 0);
if (unanalyzedCppFiles > 0) {
measureRepository.add(project, unanalyzedCppMetric, Measure.newMeasureBuilder().create(unanalyzedCppFiles));
}
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SendIssueNotificationsStep method execute.
@Override
public void execute(ComputationStep.Context context) {
BranchType branchType = analysisMetadataHolder.getBranch().getType();
if (branchType == PULL_REQUEST) {
return;
}
Component project = treeRootHolder.getRoot();
NotificationStatistics notificationStatistics = new NotificationStatistics();
if (service.hasProjectSubscribersForTypes(analysisMetadataHolder.getProject().getUuid(), NOTIF_TYPES)) {
doExecute(notificationStatistics, project);
}
notificationStatistics.dumpTo(context);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SendIssueNotificationsStep method doExecute.
private void doExecute(NotificationStatistics notificationStatistics, Component project) {
long analysisDate = analysisMetadataHolder.getAnalysisDate();
Predicate<DefaultIssue> onCurrentAnalysis = i -> i.isNew() && i.creationDate().getTime() >= truncateToSeconds(analysisDate);
NewIssuesStatistics newIssuesStats = new NewIssuesStatistics(onCurrentAnalysis);
Map<String, UserDto> assigneesByUuid;
try (DbSession dbSession = dbClient.openSession(false)) {
Iterable<DefaultIssue> iterable = protoIssueCache::traverse;
Set<String> assigneeUuids = stream(iterable.spliterator(), false).map(DefaultIssue::assignee).filter(Objects::nonNull).collect(Collectors.toSet());
assigneesByUuid = dbClient.userDao().selectByUuids(dbSession, assigneeUuids).stream().collect(toMap(UserDto::getUuid, dto -> dto));
}
try (CloseableIterator<DefaultIssue> issues = protoIssueCache.traverse()) {
processIssues(newIssuesStats, issues, assigneesByUuid, notificationStatistics);
}
if (newIssuesStats.hasIssuesOnCurrentAnalysis()) {
sendNewIssuesNotification(newIssuesStats, project, assigneesByUuid, analysisDate, notificationStatistics);
sendMyNewIssuesNotification(newIssuesStats, project, assigneesByUuid, analysisDate, notificationStatistics);
}
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PersistCrossProjectDuplicationIndexStep method execute.
@Override
public void execute(ComputationStep.Context context) {
if (!crossProjectDuplicationStatusHolder.isEnabled()) {
return;
}
try (DbSession dbSession = dbClient.openSession(true)) {
Component project = treeRootHolder.getRoot();
DuplicationVisitor visitor = new DuplicationVisitor(dbSession, analysisMetadataHolder.getUuid());
new DepthTraversalTypeAwareCrawler(visitor).visit(project);
dbSession.commit();
context.getStatistics().add("inserts", visitor.count);
}
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PersistLiveMeasuresStep method execute.
@Override
public void execute(ComputationStep.Context context) {
boolean supportUpsert = dbClient.getDatabase().getDialect().supportsUpsert();
try (DbSession dbSession = dbClient.openSession(true)) {
Component root = treeRootHolder.getRoot();
MeasureVisitor visitor = new MeasureVisitor(dbSession, supportUpsert);
new DepthTraversalTypeAwareCrawler(visitor).visit(root);
dbSession.commit();
context.getStatistics().add("insertsOrUpdates", visitor.insertsOrUpdates);
}
}
Aggregations