public static RulesProfile create() { return new RulesProfile(); }
public static RulesProfile create(String name, String language) { return new RulesProfile().setName(name).setLanguage(language); }
private RulesProfile wrap(DbSession dbSession, QProfileDto profile) { RulesProfile target = new RulesProfile(profile.getName(), profile.getLanguage()); List<OrgActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfile(dbSession, profile); 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.getRuleKey()); 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; }
public static RulesProfile create() { return new RulesProfile(); } }
public static RulesProfile create() { return new RulesProfile(); }
public static RulesProfile create(String name, String language) { return new RulesProfile().setName(name).setLanguage(language); }
public static RulesProfile create(String name, String language) { return new RulesProfile().setName(name).setLanguage(language); }
/** * Loads a provided profile. * * @param name * the profile name * @param filePath * the path of the file containins the profile * @return a provided profile. */ public RulesProfile loadProvidedProfile(String name, String filePath) { try { InputStream profileIn = getClass().getResourceAsStream(filePath); if (profileIn == null) { throw new IOException("Resource " + profileIn + " not found"); } RulesProfile profile = new RulesProfile(name, CSharp.KEY); List<Rule> initialReferential = getInitialReferential(); List<ActiveRule> configuration = importConfiguration( IOUtils.toString(profileIn, "UTF-8"), initialReferential); profile.setActiveRules(configuration); return profile; } catch (IOException e) { throw new RuntimeException( "Configuration file not found for the profile : " + name, e); } } }
private RulesProfile select(QProfile qProfile, ActiveRules activeRules) { RulesProfile deprecatedProfile = new RulesProfile(); // TODO deprecatedProfile.setVersion(qProfile.version()); deprecatedProfile.setName(qProfile.getName()); deprecatedProfile.setLanguage(qProfile.getLanguage()); for (org.sonar.api.batch.rule.ActiveRule activeRule : ((DefaultActiveRules) activeRules).findByLanguage(qProfile.getLanguage())) { Rule rule = Rule.create(activeRule.ruleKey().repository(), activeRule.ruleKey().rule()); rule.setConfigKey(activeRule.internalKey()); ActiveRule deprecatedActiveRule = deprecatedProfile.activateRule(rule, RulePriority.valueOf(activeRule.severity())); for (Map.Entry<String, String> param : activeRule.params().entrySet()) { rule.createParameter(param.getKey()); deprecatedActiveRule.setParameter(param.getKey(), param.getValue()); } } return deprecatedProfile; }
private RulesProfile wrap(DbSession dbSession, QProfileDto profile) { RulesProfile target = new RulesProfile(profile.getName(), profile.getLanguage()); List<OrgActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfile(dbSession, profile); 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.getRuleKey()); 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; }
private static RulesProfile select(QProfile qProfile, ActiveRules activeRules) { RulesProfile deprecatedProfile = new RulesProfile(); // TODO deprecatedProfile.setVersion(qProfile.version()); deprecatedProfile.setName(qProfile.getName()); deprecatedProfile.setLanguage(qProfile.getLanguage()); for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules.findByLanguage(qProfile.getLanguage())) { Rule rule = Rule.create(activeRule.ruleKey().repository(), activeRule.ruleKey().rule()); rule.setConfigKey(activeRule.internalKey()); // SONAR-6706 if (activeRule.templateRuleKey() != null) { rule.setTemplate(Rule.create(activeRule.ruleKey().repository(), activeRule.templateRuleKey())); } ActiveRule deprecatedActiveRule = deprecatedProfile.activateRule(rule, RulePriority.valueOf(activeRule.severity())); for (Map.Entry<String, String> param : activeRule.params().entrySet()) { rule.createParameter(param.getKey()); deprecatedActiveRule.setParameter(param.getKey(), param.getValue()); } } return deprecatedProfile; }