Geek Culture
Published in

Geek Culture

How to enforce Coding standards in your projects

Photo by Martin Shreder on Unsplash

When you start on any project, you want to make sure that you are following the coding standards, but what if there are multiple people working on the same project. You can’t go through all the things in the code review. so what do you do?

Well, you can integrate Checkstyle into your project. In this article, I will show you how you add Checkstyle checking in your maven project so everything someone is not following the standards, the build will fail in your CI/CD pipeline.

There are only 2 steps that you need to follow to integrate it completely.

Step 1:

Add checkstyle.xml in your project root

There are many Checkstyle standards available but I usually use the above.

Step 2:

In your pom.xml simply add the following plugin in your <build></build>

And that’s it. now when you do mvn clean install , Checkstyle will perform the static code check and if it found some violations then the build will fail.

You don’t need to do anything else in your CI/CD pipeline because your pipeline will run the build phase anyway.

Hope this helps




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store