Search in sources :

Example 1 with NewRule

use of org.sonar.api.batch.rule.internal.NewRule in project sonarqube by SonarSource.

the class RulesProvider method load.

private static Rules load(RulesLoader ref) {
    Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
    List<Rule> loadedRules = ref.load();
    RulesBuilder builder = new RulesBuilder();
    for (Rule r : loadedRules) {
        NewRule newRule = builder.add(RuleKey.of(r.getRepository(), r.getKey()));
        newRule.setName(r.getName());
        newRule.setInternalKey(r.getInternalKey());
    }
    profiler.stopInfo();
    return builder.build();
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) NewRule(org.sonar.api.batch.rule.internal.NewRule) Rule(org.sonarqube.ws.Rules.ListResponse.Rule) RulesBuilder(org.sonar.api.batch.rule.internal.RulesBuilder) NewRule(org.sonar.api.batch.rule.internal.NewRule)

Example 2 with NewRule

use of org.sonar.api.batch.rule.internal.NewRule in project sonarlint-core by SonarSource.

the class SonarQubeRulesProvider method provide.

public Rules provide(Sonarlint.Rules storageRules) {
    if (rules == null) {
        RulesBuilder builder = new RulesBuilder();
        for (Map.Entry<String, Sonarlint.Rules.Rule> entry : storageRules.getRulesByKeyMap().entrySet()) {
            Sonarlint.Rules.Rule r = entry.getValue();
            NewRule newRule = builder.add(RuleKey.of(r.getRepo(), r.getKey())).setName(r.getName()).setInternalKey(r.getInternalKey()).setSeverity(r.getSeverity()).setDescription(r.getHtmlDesc());
            if (StringUtils.isNotEmpty(r.getType())) {
                newRule.setType(r.getType());
            }
        }
        rules = builder.build();
    }
    return rules;
}
Also used : Sonarlint(org.sonarsource.sonarlint.core.proto.Sonarlint) NewRule(org.sonar.api.batch.rule.internal.NewRule) Map(java.util.Map) Rules(org.sonar.api.batch.rule.Rules) RulesBuilder(org.sonar.api.batch.rule.internal.RulesBuilder) NewRule(org.sonar.api.batch.rule.internal.NewRule)

Aggregations

NewRule (org.sonar.api.batch.rule.internal.NewRule)2 RulesBuilder (org.sonar.api.batch.rule.internal.RulesBuilder)2 Map (java.util.Map)1 Rules (org.sonar.api.batch.rule.Rules)1 Profiler (org.sonar.api.utils.log.Profiler)1 Rule (org.sonarqube.ws.Rules.ListResponse.Rule)1 Sonarlint (org.sonarsource.sonarlint.core.proto.Sonarlint)1