Must have Java code analysis Tools - Part 1

When you are working in a big team ( > 5 engineers), It is very important to have consistent code styling, development environment and code review process. As a reviewer, its very difficult I see different class naming conventions everytime, unused variables or imports etc. Hence, its very important that a team shares same coding styles and coding standards.

In this post, we will look at checkstyle , a tool that helps developers adhere to coding standards. Checkstyle operates at the source level, i.e. even before the compile phase has started

Running with build process

The code analysis tools such as checkstyle are most useful when integrated with build process as useful reports can be generated and even build can be failed to enforce the standards.

For example, We use the following section in pom.xml to run checkstyle as part of build process


Here setting failsOnError attribute true causes the build to fail if violations are fail. The file checks.xml specifies the styling configuration. I used the modified google check style to make our own styling conventions.