Python – Sonar : is there a way to add custom rules for python using Java

Sonar : is there a way to add custom rules for python using Java… here is a solution to the problem.

Sonar : is there a way to add custom rules for python using Java

According to the documentation, there are two ways to include custom rules:

  • Write coding rules in Java through the SonarQube plugin
  • Add XPath rules directly through the SonarQube web interface

According to link sonar-python doesn’t support the first way I want to use.

I wonder if anything has changed and will this feature be supported? Where can I find tutorials like this for Java if this feature is supported? Or is there only one way to create your own sensor and use the implemented python parser?

Solution

Writing custom rules for SonarPython in Java is not supported.
It is not actively enabled at this time.
But if the rule isn’t specific to your context and useful for every python code, you can contribute by writing descriptions and incompatible/compatible code examples in this google group:
groups.google.com/sonarqube or you can do it in Create a pull request on github.com/SonarSource/sonar-python

Related Problems and Solutions