use of org.sonar.api.profiles.RulesProfile in project sonarqube by SonarSource.
the class XooBasicProfile method createProfile.
@Override
public RulesProfile createProfile(ValidationMessages validation) {
final RulesProfile profile = RulesProfile.create("Basic", Xoo.KEY);
profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR);
return profile;
}
use of org.sonar.api.profiles.RulesProfile in project sonarqube by SonarSource.
the class XooFakeImporter method importProfile.
@Override
public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
RulesProfile rulesProfile = RulesProfile.create();
rulesProfile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, "x1"), RulePriority.CRITICAL);
return rulesProfile;
}
use of org.sonar.api.profiles.RulesProfile in project sonarqube by SonarSource.
the class Xoo2BasicProfile method createProfile.
@Override
public RulesProfile createProfile(ValidationMessages messages) {
RulesProfile profile = RulesProfile.create("Basic", Xoo2.KEY);
// so UGLY
profile.activateRule(Rule.create(XooRulesDefinition.XOO2_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR);
return profile;
}
use of org.sonar.api.profiles.RulesProfile in project sonarqube by SonarSource.
the class QProfileExporters method wrap.
private RulesProfile wrap(QualityProfileDto profile) {
try (DbSession dbSession = dbClient.openSession(false)) {
RulesProfile target = new RulesProfile(profile.getName(), profile.getLanguage());
List<ActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfileKey(dbSession, profile.getKey());
List<ActiveRuleParamDto> activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDto::getId));
ListMultimap<Integer, ActiveRuleParamDto> activeRuleParamsByActiveRuleId = FluentIterable.from(activeRuleParamDtos).index(ActiveRuleParamDto::getActiveRuleId);
for (ActiveRuleDto activeRule : activeRuleDtos) {
// TODO all rules should be loaded by using one query with all active rule keys as parameter
Rule rule = ruleFinder.findByKey(activeRule.getKey().ruleKey());
org.sonar.api.rules.ActiveRule wrappedActiveRule = target.activateRule(rule, RulePriority.valueOf(activeRule.getSeverityString()));
List<ActiveRuleParamDto> paramDtos = activeRuleParamsByActiveRuleId.get(activeRule.getId());
for (ActiveRuleParamDto activeRuleParamDto : paramDtos) {
wrappedActiveRule.setParameter(activeRuleParamDto.getKey(), activeRuleParamDto.getValue());
}
}
return target;
}
}
use of org.sonar.api.profiles.RulesProfile in project sonarqube by SonarSource.
the class RegisterQualityProfiles method start.
public void start() {
Profiler profiler = Profiler.create(Loggers.get(getClass())).startInfo("Register quality profiles");
DbSession session = dbClient.openSession(false);
try {
List<ActiveRuleChange> changes = new ArrayList<>();
ListMultimap<String, RulesProfile> profilesByLanguage = profilesByLanguage();
for (String language : profilesByLanguage.keySet()) {
List<RulesProfile> defs = profilesByLanguage.get(language);
if (verifyLanguage(language, defs)) {
changes.addAll(registerProfilesForLanguage(session, language, defs));
}
}
activeRuleIndexer.index(changes);
profiler.stopDebug();
} finally {
session.close();
}
}
Aggregations