I am trying to create a custom Java rule. For now I just want to try somthing that sounds easy which is not allowing numbers in th method names.
I’ve seen that there is a template called [Track uses of disallowed methods]. This is the one I wanted to use but maybe I am wrong on this too.
The thing is that I have no idea how to use it. I tried to follow this tutorial : Adding coding rules . The first step is to create a SonarQube plugin and I have no idea how to do it.
I’ve seen few youtube tutorials that explain that they are creating a java class in order to explain the rule but still I don’t know how to incorporate this file into SonarQube.
If someone can explain me how to achieve this task, I would be very thanksful.
Here are the tools I am using
Apache Maven 3.9.1
I am deploying SonarQube in localhost
Thanks a lot
The template rule you are referring to will probably not help you, it is about disallowing a specific method.
As you have guessed, adding a custom rule is the way to go.
Here is a small reminder for Java custom rules:
CUSTOM RULES 101 is the go-to guide when starting to implement custom rules for Java, it is regularly updated.
- For rules implementation examples, you can directly look into the rules of the Java analyzer itself, it contains hundreds of examples (just make sure to use only what is provided in the public API).
Hope it gives you clues to continue your research.
Thank you very much
Thanks to that + this youtube tutorial SonarQube Writing Custom Rules For Java - Implementing Custom Rule - YouTube, I am able to create a Java rules.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.