While technology improves very quickly, systems are getting more complex and easy to be broken. Besides that, having really good quality code is extremely important and checkstyle is a very simple but so attractive solution for this. It is called like a “Automated Code Review Tool” which is very meaningfull.
In many cases, a QA team or a “guru” code reviewer from the team is assigned to review the code manually, based on coding standards used as guidelines for development. Manually reviewing millions of lines of code is a tedious job, though; ultimately as exhausting as it must be exhaustive. While you have these kind of situations, checkstyle is in your help.
Checkstyle, is a static code analysis tool used in software development for checking if Java source code complies with coding rules. As it is a static code analysis tool, it has some built-in rules inside which is defined by Sun and Google which can be found here. As they are built-in rules and generic, the trick to a successful automated code review is to combine the built-in rules with custom ones. The more refined your rules, the more truly automated your code review becomes. So, I strongly recommend to use your own ruleset to have the best quality automated code review testing.
Let me explain you my use case with checkstyle. I decided to prepare an “Automated Fortune Machine for Turkish Coffee” that gets pictures of cups and the information about the customer. This app will be able to return a fortune telling response which has machine learning algorithms in it to perform the best responses to the customer. I used checkstyle in my new-created project and when I check my code, everything is very clear, all the code has javadoc, there is no unnecessary lines or imports and the code is written with good best practices.
To have this really good experience, the changes that I made to make checkstyle work is extremely easy. I integrated it with Maven by using maven checktyle plugin;
And after that, when I run checkstyle check with maven, then I can easily see the problems;
[INFO] There is 1 error reported by Checkstyle 6.11.2 with /Users/isioben/Desktop/MyWorld/Forteller/checkstyle/checkstyle.xml ruleset.
[ERROR] src/main/java/com/dizxlabs/ai/store/ISentenceStore.java:[50,5] (javadoc) JavadocMethod: Missing a Javadoc comment.
As a summary, I strongly recommend all the java developers to use checkstyle in their apps!