Skip to main content

JENKINS : CONTINUOUS INSPECTION USING CHECK STYLE

Check style is a code static analysis tool to help programmers to write java code and to evaluate coding standard such as
> Avoid multiple blank lines
> Removing unused variables
> Enforcing correct indentations etc

Assume we have configured a maven-project to build our code.Along with this we will include checkstyle for continuous inspection.
First we have to install checkstyle plugin.From Manage Jenkins > Manage plugins. Now select checkstyle plugin and install it.


Now go to our project maven-new.Under build action, along with clean package we will include checkstyle:checkstyle.
Under post build step select publish checklist analytic result and leave the blank space, then the default **/checkstyle-result.xml is used.Then click save.

 Now build our project.We can see a new checkstyle warning tab came on left. Now under warnings we can see many warnings.we have to fix this.


 Under categories we can see various warnings.First we will fix warnings under checks. Click on checks.Now click on details.Thereare 2 check warnings.


 First we will clear parameter warning.For that click on greeter java 16.It will display our file.




Now clone our git hub repository.Make changes in necessery filre (ie, greeter.java).

We will add final before String someone.Similary correct all the warnings.Then commit those changes to our github repository.As we have enables build using git webhook. It will automatically trigger a build once new commit to repository is made.


Checkstyle Trend output:

In this check style trend red colour shows new warnings and blue color shows number of fixed warnings in build.