use of org.sonarsource.sonarlint.core.client.api.exceptions.MessageException in project sonarlint-core by SonarSource.
the class SonarQubeActiveRulesProvider method createNewActiveRule.
private static void createNewActiveRule(ActiveRulesBuilder builder, ActiveRule activeRule, Sonarlint.Rules storageRules, String language, Rules rules) {
RuleKey ruleKey = RuleKey.of(activeRule.getRepo(), activeRule.getKey());
Rule rule = rules.find(ruleKey);
Sonarlint.Rules.Rule storageRule;
try {
storageRule = storageRules.getRulesByKeyOrThrow(ruleKey.toString());
} catch (IllegalArgumentException e) {
throw new MessageException("Unknown active rule in the quality profile of the project. Please update the SonarQube server binding.");
}
NewActiveRule newActiveRule = builder.create(ruleKey).setLanguage(language).setName(rule.name()).setInternalKey(rule.internalKey()).setSeverity(activeRule.getSeverity());
if (!StringUtils.isEmpty(storageRule.getTemplateKey())) {
RuleKey templateRuleKey = RuleKey.parse(storageRule.getTemplateKey());
newActiveRule.setTemplateRuleKey(templateRuleKey.rule());
}
for (Map.Entry<String, String> param : activeRule.getParamsMap().entrySet()) {
newActiveRule.setParam(param.getKey(), param.getValue());
}
newActiveRule.activate();
}
use of org.sonarsource.sonarlint.core.client.api.exceptions.MessageException in project sonarlint-core by SonarSource.
the class SonarLintWrappedExceptionTest method extractMessageException.
@Test
public void extractMessageException() {
MessageException e = new MessageException("a");
Exception a = new IllegalStateException("a", new IllegalStateException("b", e));
assertThat(SonarLintWrappedException.wrap(a)).isEqualTo(e);
}
Aggregations