/** {@inheritDoc} */ @Override public RulesProfile importProfile(Reader reader, ValidationMessages messages) { RulesProfile profile = RulesProfile.create(); profile.setLanguage(CSharpConstants.LANGUAGE_KEY); try { List<StyleCopRule> styleCopConfig = StyleCopRuleParser.parse(IOUtils.toString(reader)); for (StyleCopRule styleCopRule : styleCopConfig) { if (styleCopRule.isEnabled()) { String ruleName = styleCopRule.getName(); Rule rule = ruleFinder.find(RuleQuery.create().withRepositoryKey(getKey()).withKey(ruleName)); if (rule != null) { String rawPriority = styleCopRule.getPriority(); RulePriority rulePriority = RulePriority.MINOR; if (StringUtils.isNotEmpty(rawPriority)) { rulePriority = RulePriority.valueOfString(rawPriority); } profile.activateRule(rule, rulePriority); } } } } catch (IOException e) { messages.addErrorText("Failed to read the profile to import: " + e.getMessage()); } return profile; }