sonarqube - plugin for adding issues referring to manual rules into sonar -
import org.sonar.api.component.resourceperspectives; public class mysensor extends sensor { private final resourceperspectives perspectives; public mysensor(resourceperspectives p) { this.perspectives = p; } public void analyse(project project, sensorcontext context) { resource myresource; // set issuable issuable = perspectives.as(issuable.class, myresource); if (issuable != null) { // can used issue issue = issuable.newissuebuilder() //repository : pmd, key : avoidarrayloops .setrulekey(rulekey.of("pmd", "avoidarrayloops")) .setline(10) .build(); //works issuable.addissue(issue); issue issue2 = issuable.newissuebuilder() //repository : manual, key : performance .setrulekey(rulekey.of("manual", "performance")) .setline(10) .build(); // doesn't work issuable.addissue(issue2); } } }
when try add issue "issue" referring pmd rule avoidarrayloops works. more generally, when try add issues referring pmd or checkstyle rules works.
however, when try add issues referring manual rules such issue "issue2", doesn't work. have created manually rule "performance" rule performance exists in list of manual rules in sonar.
i know if impossible add issues referring manual rules or if not using right parameters method rulekey.of.
thanks
one reason why custom issue not shown in sonar may haven't enabled rule.
select settings - quality profiles, click on quality profile, select tab "coding rules", set activation "any", click search , check whether rule being displayed here.
if so, check checkbox next , select severity. now, rule violations displayed in sonar.
Comments
Post a Comment