Search in sources :

Example 1 with DefaultRuleDetails

use of org.sonarsource.sonarlint.core.container.model.DefaultRuleDetails in project sonarlint-core by SonarSource.

the class StorageRuleDetailsReader method apply.

@Override
public RuleDetails apply(String ruleKeyStr) {
    Sonarlint.Rules rulesFromStorage = storageReader.readRules();
    RuleKey ruleKey = RuleKey.parse(ruleKeyStr);
    Sonarlint.Rules.Rule rule = rulesFromStorage.getRulesByKeyMap().get(ruleKeyStr);
    if (rule == null) {
        throw new IllegalArgumentException("Unable to find rule with key " + ruleKey);
    }
    String type = StringUtils.isEmpty(rule.getType()) ? null : rule.getType();
    return new DefaultRuleDetails(ruleKeyStr, rule.getName(), rule.getHtmlDesc(), rule.getSeverity(), type, rule.getLang(), Collections.<String>emptySet(), rule.getHtmlNote());
}
Also used : RuleKey(org.sonar.api.rule.RuleKey) DefaultRuleDetails(org.sonarsource.sonarlint.core.container.model.DefaultRuleDetails) Sonarlint(org.sonarsource.sonarlint.core.proto.Sonarlint)

Example 2 with DefaultRuleDetails

use of org.sonarsource.sonarlint.core.container.model.DefaultRuleDetails in project sonarlint-core by SonarSource.

the class StandaloneGlobalContainer method getRuleDetails.

public RuleDetails getRuleDetails(String ruleKeyStr) {
    RuleKey ruleKey = RuleKey.parse(ruleKeyStr);
    DefaultRule rule = (DefaultRule) rules.find(ruleKey);
    if (rule == null) {
        throw new IllegalArgumentException("Unable to find rule with key " + ruleKey);
    }
    Repository repo = rulesDefinitions.repository(rule.key().repository());
    return new DefaultRuleDetails(ruleKeyStr, rule.name(), rule.description(), rule.severity(), rule.type(), repo.language(), repo.rule(rule.key().rule()).tags(), "");
}
Also used : DefaultRule(org.sonar.api.batch.rule.internal.DefaultRule) Repository(org.sonar.api.server.rule.RulesDefinition.Repository) PluginRepository(org.sonarsource.sonarlint.core.plugin.PluginRepository) RuleKey(org.sonar.api.rule.RuleKey) DefaultRuleDetails(org.sonarsource.sonarlint.core.container.model.DefaultRuleDetails)

Aggregations

RuleKey (org.sonar.api.rule.RuleKey)2 DefaultRuleDetails (org.sonarsource.sonarlint.core.container.model.DefaultRuleDetails)2 DefaultRule (org.sonar.api.batch.rule.internal.DefaultRule)1 Repository (org.sonar.api.server.rule.RulesDefinition.Repository)1 PluginRepository (org.sonarsource.sonarlint.core.plugin.PluginRepository)1 Sonarlint (org.sonarsource.sonarlint.core.proto.Sonarlint)1