You are mixing multiple concepts. Custom rules are extra rules that you develop, based on SonarSource analyzers. Basically we provide an API to simplify the coding of new rules (providing an AST, so that you d’ont have to handle the parsing/inference yourself). The repo https://github.com/SonarSource/sonar-custom-rules-examples is about that. For custom rules, you should not implement a Sensor, but instead the extension point provided by the custom rule API. In the case of SonarJava, the entry point is CheckRegistrar that returns a list of Checks.
Now if you want to develop your own rules, without relying on SonarJava API, you have two options:
If you know in advance the list of possible rules, and want to configure the rules activation/severity/params from SonarQube UI, you should use “normal” rules. Implement RulesDefinition extension point (similar to your exemple above), and then in your Sensor use the method newIssue to create an issue for a specific rule key. Caution: the rule should be activated in the project quality profile to have it ultimately reported in SonarQube.
If you don’t know the list of rules, or more generically you simply want to quickly import third party report of issues, where the rules configuration is managed outside SonarQube, then you can use newExternalIssue, with or without newAdHocRule to give more details about the rule. Note that to import external issues, you could also not develop any Java plugin, but simply feed the scanner with the issue report converted to a specific XML format.
I still need each issue to have own rich details (text describing reasons why issue happens and some link to point how it could be solved)
I see that each issue had comments and I want to use them to reach my goal.
Could you provide some hint on how I could add comments to new issues I created
I’m Tamir, the Product Manager that works with Vitalii.
What we’re essentially trying to accomplish is to link between an individual exception error to the OverOps root cause. The problem is that each exception has a unique link to our OverOps Automated Root Cause screen (tale.html), and we’re not sure what’s the best way to develop that - whether it’s with Custom Rules and/or Templates.
How am supposed to activate it without use of the UI
I want this qualityProfile activate via my custome plugin only ( through code )
I already have ruleDefinition and QualityProfile created using BuilinQualityProfile which is showing me perfectly inside of SonarQube. However I have to manually set that profile to project ( I want this to be automatically activated for new project)
If you are contributing rules for an existing language, this is not possible. For a language, there will be a default built in quality profile (Sonar Way) that the owner of the language defined.
We don’t want to have third party plugins contributing extra rules to this default profile.
So if you are contributing java rules, you’ll have to tell your users to activate your rules in their quality profile.