How to write a simple rule to check string type of variable like "1111"

Hello

I have read writing custom java rules 101, that’s a good tutorial for beginner, and now I want to write something for practice.

I want to build a rule to scan my project and help me to find some string variables which were written consecutive, duplicate, obviously looks like someone wrote it arbitrarily. For instance, “1111”, “aaaaa”. At first I want to figure out it by referring web-api https://next.sonarqube.com/sonarqube/web_api/, but unfortunately I could not find some interpretations of Kind, symbol or other api to help me work out it.

So could some guys give me some hints to achieve my target? How to write this rule?

thanks!

Hi all,

I have figured out by myself, Kind.String_literal and literalTree are the key of this topic. Further more, I could also use Kind.variable and variableTree to do more intricate scenarios. After I confirmed the type of node and tree, other things just to wrote some logic like regex to verification.

But I still hope sonarqube team could provide a precise api document, so that I needn’t to find some interpretations from sources, maybe I didn’t find the right way? haha