use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class NewEffortAggregator method beforeComponent.
@Override
public void beforeComponent(Component component) {
try (DbSession dbSession = dbClient.openSession(false)) {
List<IssueChangeDto> changes = dbClient.issueChangeDao().selectChangelogOfNonClosedIssuesByComponent(dbSession, component.getUuid());
for (IssueChangeDto change : changes) {
changesByIssueUuid.put(change.getIssueKey(), change);
}
}
counter = new NewEffortCounter(calculator);
counterByComponentRef.put(component.getReportAttributes().getRef(), counter);
for (Component child : component.getChildren()) {
NewEffortCounter childSum = counterByComponentRef.remove(child.getReportAttributes().getRef());
if (childSum != null) {
counter.add(childSum);
}
}
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PersistCrossProjectDuplicationIndexStep method execute.
@Override
public void execute() {
if (!crossProjectDuplicationStatusHolder.isEnabled()) {
return;
}
try (DbSession dbSession = dbClient.openSession(true)) {
Component project = treeRootHolder.getRoot();
new DepthTraversalTypeAwareCrawler(new DuplicationVisitor(dbSession, analysisMetadataHolder.getUuid())).visit(project);
dbSession.commit();
}
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class UpdateQualityProfilesLastUsedDateStep method execute.
@Override
public void execute() {
try (DbSession dbSession = dbClient.openSession(true)) {
Component root = treeRootHolder.getRoot();
Metric metric = metricRepository.getByKey(QUALITY_PROFILES_KEY);
Set<QualityProfile> qualityProfiles = parseQualityProfiles(measureRepository.getRawMeasure(root, metric));
if (qualityProfiles.isEmpty()) {
return;
}
List<QualityProfileDto> dtos = dbClient.qualityProfileDao().selectByKeys(dbSession, qualityProfiles.stream().map(QualityProfile::getQpKey).collect(Collectors.toList()));
dtos.addAll(getAncestors(dbSession, dtos));
long analysisDate = analysisMetadataHolder.getAnalysisDate();
dtos.forEach(dto -> {
dto.setLastUsed(analysisDate);
dbClient.qualityProfileDao().update(dbSession, dto);
});
dbSession.commit();
}
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class ValidateProjectStep method execute.
@Override
public void execute() {
try (DbSession dbSession = dbClient.openSession(false)) {
Component root = treeRootHolder.getRoot();
List<ComponentDto> baseModules = dbClient.componentDao().selectEnabledModulesFromProjectKey(dbSession, root.getKey());
Map<String, ComponentDto> baseModulesByKey = from(baseModules).uniqueIndex(ComponentDto::key);
ValidateProjectsVisitor visitor = new ValidateProjectsVisitor(dbSession, dbClient.componentDao(), baseModulesByKey);
new DepthTraversalTypeAwareCrawler(visitor).visit(root);
if (!visitor.validationMessages.isEmpty()) {
throw MessageException.of("Validation of project failed:\n o " + MESSAGES_JOINER.join(visitor.validationMessages));
}
}
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class IntegrateCrossProjectDuplicationsTest method add_duplication_for_java_even_when_no_token.
@Test
public void add_duplication_for_java_even_when_no_token() {
Component javaFile = builder(FILE, 1).setKey(ORIGIN_FILE_KEY).setFileAttributes(new FileAttributes(false, "java", 10)).build();
Collection<Block> originBlocks = singletonList(// This block contains 0 token
new Block.Builder().setResourceId(ORIGIN_FILE_KEY).setBlockHash(new ByteArray("a8998353e96320ec")).setIndexInFile(0).setLines(30, 45).setUnit(0, 0).build());
Collection<Block> duplicatedBlocks = singletonList(new Block.Builder().setResourceId(OTHER_FILE_KEY).setBlockHash(new ByteArray("a8998353e96320ec")).setIndexInFile(0).setLines(40, 55).build());
underTest.computeCpd(javaFile, originBlocks, duplicatedBlocks);
assertThat(duplicationRepository.getDuplications(ORIGIN_FILE)).containsExactly(crossProjectDuplication(new TextBlock(30, 45), OTHER_FILE_KEY, new TextBlock(40, 55)));
}
Aggregations