How to configure CheckStyle and Findbugs plugins to IntelliJ IDEA for WSO2 products

From WSO2 POM version 4 onward, CheckStyle and Findbugs maven plugins are enabled by default. So the code won’t compile if there are any CheckStyle or Findbugs issues present. Maven will complain about what are the issues there with the code. Until you fix everyone of them, you won’t be able to compile the code. (Of course you can disable CheckStyle and Findbugs) You can easily fix these issues beforehand by integrating CheckStyle and Findbugs plugins to IntelliJ IDEA.

Installing CheckStyle Plugin

First download the latest plugin (Or the version that is compatible with IDEA version) from plugins website. Then install it to the IDEA by opening File -> Settings -> Plugins and Install plugin from the disk.

Image for post
Image for post

After installing it, Restart the IDEA. Then go to File -> Settings -> Other Settings -> Checkstyle. Click positive mark to add a new configuration file. Select “Check style file accessible via HTTP” option and add https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/checkstyle.xml URL.

Image for post
Image for post

Click next and save the configuration. Now the CheckStyle plugin will be available and you can run it in the project to find the issues.

NOTE:

If you are using a newer version of CheckStyle plugin ( > v4.35.0), then you will get an error if you try to directly add this URL. Reason for this is check style version for the file is 7.1 and newer versions of the plugin expects higher version file. To change that, first go to the plugin and change the check style version to 7.1 and hit apply. Then add the URL. Below screen shot is from the CheckStyle plugin version 5.17.0

Image for post
Image for post

Installing Findbugs Plugin

Download the Findbugs plugin from the site and install it by following the same steps mentioned above.

After installing the plugin, restart the IDEA and go to File -> Settings -> Other Settings -> FindBugs-IDEA. Then go to Report tab and select “Maximal” for the “Analysis Effort” and “Low” for the “Minimum confidence to report”

Image for post
Image for post

After that, you can run the Findbugs on the project and find what are the issues.

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