use of org.sonar.server.qualityprofile.QualityProfile 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.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class ComputeQProfileMeasureStepTest method add_quality_profile_measure_on_project.
@Test
public void add_quality_profile_measure_on_project() throws Exception {
treeRootHolder.setRoot(MULTI_MODULE_PROJECT);
QualityProfile qpJava = createQProfile(QP_NAME_1, LANGUAGE_KEY_1);
QualityProfile qpPhp = createQProfile(QP_NAME_2, LANGUAGE_KEY_2);
analysisMetadataHolder.setQProfilesByLanguage(ImmutableMap.of(LANGUAGE_KEY_1, qpJava, LANGUAGE_KEY_2, qpPhp));
underTest.execute();
assertThat(measureRepository.getAddedRawMeasures(PROJECT_REF).get(QUALITY_PROFILES_KEY)).extracting("data").containsOnly(toJson(qpJava, qpPhp));
}
use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class QualityProfileEventsStepTest method no_more_used_event_if_qp_no_more_listed.
@Test
public void no_more_used_event_if_qp_no_more_listed() {
QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1);
mockMeasures(treeRootHolder.getRoot(), arrayOf(qp), null);
Language language = mockLanguageInRepository(LANGUAGE_KEY_1);
underTest.execute();
verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
verifyNoMoreInteractions(eventRepository);
verifyEvent(eventArgumentCaptor.getValue(), "Stop using '" + qp.getQpName() + "' (" + language.getName() + ")", null);
}
use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class QualityProfileEventsStepTest method no_more_used_event_uses_language_key_in_message_if_language_not_found.
@Test
public void no_more_used_event_uses_language_key_in_message_if_language_not_found() {
QualityProfile qp = qp(QP_NAME_1, LANGUAGE_KEY_1);
mockMeasures(treeRootHolder.getRoot(), arrayOf(qp), null);
mockLanguageNotInRepository(LANGUAGE_KEY_1);
underTest.execute();
verify(eventRepository).add(eq(treeRootHolder.getRoot()), eventArgumentCaptor.capture());
verifyNoMoreInteractions(eventRepository);
verifyEvent(eventArgumentCaptor.getValue(), "Stop using '" + qp.getQpName() + "' (" + qp.getLanguageKey() + ")", null);
}
use of org.sonar.server.qualityprofile.QualityProfile in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStep method loadQualityProfiles.
private void loadQualityProfiles(ScannerReport.Metadata reportMetadata) {
analysisMetadata.setQProfilesByLanguage(reportMetadata.getQprofilesPerLanguageMap().values().stream().collect(toMap(QProfile::getLanguage, qp -> new QualityProfile(qp.getKey(), qp.getName(), qp.getLanguage(), new Date(qp.getRulesUpdatedAt())))));
analysisMetadata.setScannerPluginsByKey(reportMetadata.getPluginsByKeyMap().values().stream().collect(toMap(Plugin::getKey, p -> new ScannerPlugin(p.getKey(), getBasePluginKey(p), p.getUpdatedAt()))));
}
Aggregations