use of org.sonarsource.sonarlint.core.proto.Sonarlint.QProfiles.QProfile in project sonarlint-core by SonarSource.
the class QualityProfilesUpdateChecker method checkForUpdates.
public void checkForUpdates(DefaultStorageUpdateCheckResult result) {
QProfiles serverQualityProfiles = qualityProfilesDownloader.fetchQualityProfiles();
QProfiles storageQProfiles = storageReader.readQProfiles();
Map<String, QProfile> serverPluginHashes = serverQualityProfiles.getQprofilesByKeyMap();
Map<String, QProfile> storagePluginHashes = storageQProfiles.getQprofilesByKeyMap();
MapDifference<String, QProfile> pluginDiff = Maps.difference(storagePluginHashes, serverPluginHashes);
if (!pluginDiff.areEqual()) {
for (Map.Entry<String, QProfile> entry : pluginDiff.entriesOnlyOnLeft().entrySet()) {
result.appendToChangelog(String.format("Quality profile '%s' for language '%s' removed", entry.getValue().getName(), entry.getValue().getLanguageName()));
}
for (Map.Entry<String, QProfile> entry : pluginDiff.entriesOnlyOnRight().entrySet()) {
result.appendToChangelog(String.format("Quality profile '%s' for language '%s' added", entry.getValue().getName(), entry.getValue().getLanguageName()));
}
for (Map.Entry<String, ValueDifference<QProfile>> entry : pluginDiff.entriesDiffering().entrySet()) {
result.appendToChangelog(String.format("Quality profile '%s' for language '%s' updated", entry.getValue().rightValue().getName(), entry.getValue().rightValue().getLanguageName()));
}
}
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.QProfiles.QProfile in project sonarlint-core by SonarSource.
the class SonarQubeActiveRulesProvider method provide.
public ActiveRules provide(Sonarlint.Rules storageRules, Sonarlint.QProfiles qProfiles, StorageReader storageReader, Rules rules, ConnectedAnalysisConfiguration analysisConfiguration, Languages languages) {
if (activeRules == null) {
Map<String, String> qProfilesByLanguage = loadQualityProfilesFromStorage(qProfiles, storageReader, analysisConfiguration);
ActiveRulesBuilder builder = new ActiveRulesBuilder();
for (Map.Entry<String, String> entry : qProfilesByLanguage.entrySet()) {
String language = entry.getKey();
if (languages.get(language) == null) {
continue;
}
String qProfileKey = entry.getValue();
QProfile qProfile = qProfiles.getQprofilesByKeyOrThrow(qProfileKey);
if (qProfile.getActiveRuleCount() == 0) {
LOG.debug(" * {}: {} (0 rules)", language, qProfileKey);
continue;
}
Sonarlint.ActiveRules activeRulesFromStorage = storageReader.readActiveRules(qProfileKey);
LOG.debug(" * {}: {} ({} rules)", language, qProfileKey, activeRulesFromStorage.getActiveRulesByKeyMap().size());
for (ActiveRule activeRule : activeRulesFromStorage.getActiveRulesByKeyMap().values()) {
createNewActiveRule(builder, activeRule, storageRules, language, rules);
}
}
activeRules = builder.build();
}
return activeRules;
}
Aggregations