SonarQube. Custom repository with custom rules. Included rules is presented as Rule Template

469 Views Asked by At

It was necessity to write my own repository with a bunch of specific python rules and I wouldn't like to use Xpath to include it in sonar context.

I've implemented my own module where I used almost the same implementation from sonar-python modules: Sensor, ProfileDefinition, RulesDefinition.

I've only changed implementation of CheckList and excluded from Sensor a highlighting and metrics.Basing on this parts I've created Plugin and added them in sonar context.

Everything work perfect, my custom rules raises issues but all these rules are flagged as Rule Template and I cannot create new QualityProfile basing on it.

What do I omit?

1

There are 1 best solutions below

0
On

Currently SonarPython only support XPath rules and not custom java rules.

But, if you create your own sensor, when you declare your RulesDefinition, you should NOT call setTemplate(true)

NewRule rule = ...
....
rule.setTemplate(true);