How do I write custom rules for .sql files using SSLR toolkit?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    – sonarqube 8.3.1, sonar scanner 4.3.0, sslr-plsql-toolkit-3.4.1
  • what are you trying to achieve – I am trying to build custom rules for .sql files
  • what have you tried so far to achieve this – I have installed sslr-plsql-toolkit-3.4.1 where the AST and XML code for my sql file are successfully generated. I want to know how I can write XPath query to create custom rules for sql files.

Hello,

I guess you looked already at the documentation and in it we say that you should find your way to write the XPath query using any external tool handling XML+XPath. Said differently we don’t provide a comprehensive XPath documentation, others do that better than us.

This said, before thinking about writing your own rules, did you think about suggesting these rules in the New Rules section of this forum. It could be valuable to exchange first about what and why you want new rules, be challenged by the community and find some help to write the rule itself. In the past, by following this process SonarSource decided to take the lead on the suggested rules and they were finally integrated as built-in rules.

Regards
Alex

1 Like