If you are targeting a Java rule, I believe the best place to start is custom rules 101. Thanks to this guide, you will have a simple rule working.
Then, you can have a look at the rules that are already implemented. You can find here more than 500 examples. Here is an example of rule targeting for loop for instance.
Of course, it requires knowledge about abstract syntax trees (AST), visitor pattern, … to understand exactly what going on. Hopefully, it is quite common computer science topics, you will find plenty of documentation online.
Also note that if you believe the rule you want to implement could help many people because it is a common mistake or known bad pattern, you can also propose it in the “Suggest new features” category.