Help with custom rules

Hi, I am trying to create a custom rule and i dont know how.
First of all i had to say that i read and try Custom rules 101 and I have followed the steps and I have managed to create the rule.
Now i was trying to create a simple rule for Java:
The rule is that I search for embeded SQL statements, for this, I want to search each line for the word SELECT.

I was trying to do this:

public List<Kind> nodesToVisit() {
	return Collections.singletonList(Kind.FOR_EACH_STATEMENT); 

public void visitNode(Tree tree) {
  StatementTree method = (StatementTree) tree;
  //Strategy: Look at each phrase to find a "SELECT", If found, reportIssue
  String line = method.toString();
  String[] words= line.split(" ");
  for(int i = 0;i<words.length ;i++) {
	  if(words[i].equals("SELECT")) {
		  reportIssue(tree, "SQL detected");

I don,t know and i cant find info about Kind. Simply i read this and I thought that FOR_EACH_STTEMENT could be what I needed.

If anyone could help me I would really appreciate it. Thanks :innocent:

Hello @Jose_Fernandez

When working with custom rules a nice source of information is the Java analyzer itself, with hundreds of examples! I understand that the whole code is quite complex to understand, but many rule implementation themselves are not that complex, and I’m sure you can already find much information there.

As a general observation, you should avoid relying on tokens or string representation of nodes (unless there is a specific getter, like value() for LiteralTree for example), as you are doing here: String line = method.toString();.
For example, BooleanMethodReturnCheck is reporting all nodes return null; in a method returning Boolean, maybe you can take inspiration of what is done here for your rule.