Enforcing Coding Standards using Checkstyle

Checkstyle is a great tool for enforcing agreed code style across a team.

To make sure everyone in your team is observing the agreed code style. You can get the checkstyle maven plugin to fail the build if a rule is violated

Here is a simple example demonstration a simple project with checkstyle rules applied. Here is an example of checkstyle failing our build, we have setup checkstyle config in this example project to enforce left curly is a line by itself, but as you can see in the example project, the Hello class has violated the rule.

Checkstyle has an an extensive list of checks you can configure and you even write your checks aswell.

checkstyle-build-check-goal

Leave a Reply

Your email address will not be published.