Search in sources :

Example 21 with ActiveRule

use of org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule in project sonarqube by SonarSource.

the class CommonRule method processFile.

@CheckForNull
public DefaultIssue processFile(Component file, String fileLanguage) {
    DefaultIssue issue = null;
    RuleKey ruleKey = RuleKey.of(commonRepositoryForLang(fileLanguage), key);
    Optional<ActiveRule> activeRule = activeRulesHolder.get(ruleKey);
    if (activeRule.isPresent()) {
        CommonRuleIssue cri = doProcessFile(file, activeRule.get());
        if (cri != null) {
            issue = new DefaultIssue();
            issue.setGap(cri.effortToFix);
            issue.setMessage(cri.message);
            issue.setRuleKey(ruleKey);
            issue.setSeverity(activeRule.get().getSeverity());
            issue.setLine(null);
            issue.setChecksum("");
        }
    }
    return issue;
}
Also used : RuleKey(org.sonar.api.rule.RuleKey) ActiveRule(org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule) DefaultIssue(org.sonar.core.issue.DefaultIssue) CheckForNull(javax.annotation.CheckForNull)

Aggregations

ActiveRule (org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule)21 Test (org.junit.Test)19 DefaultIssue (org.sonar.core.issue.DefaultIssue)15 RuleKey (org.sonar.api.rule.RuleKey)2 HashMap (java.util.HashMap)1 CheckForNull (javax.annotation.CheckForNull)1