Adding custom template for a language

Must-share information (formatted with Markdown):

  • which versions are you using SonarQube 8.5.1
  • what are you trying to achieve: add custom Swift rules
  • what have you tried so far to achieve this: read Sonar docs on custom rules

I need to add a custom rule for Swift code, I’ve checked the doc on this topic: Rules so I can create a custom rule from an existing rule template. However, there’s no rule template available for Swift language, so I wonder if there’s a way I can add a template for Swift and start from there?

Screen Shot 2022-04-07 at 1.09.19 pm

Attached is a screenshot, while other languages have number of rule templates, there’s 0 for Swift (I had to search “swift” to reveal it in the list).


Hey there.

Rule templates are very specific (relying on a query language like xPath to be available for the language), and typically for a very narrow category of rules (tracking things that should not be there). It so happens that none of these are available for Swift.

If you have an idea for a new rule for the Swift language, feel free to make a post in the New rules - Sonar Community category.

Please also take note that your SonarQube version is EOL – you should update to v8.9 LTS at your earliest convenience.

Thanks a lot! I’ll have a look.