Skip to content

Guide on integrate Checkstyle with local IDE

Overview

By reading this document, you will know how to integrate Checkstyle plugin with HEA configuration into your local IDE. Currently only IntelliJ IDEA and Eclipse are covered.

💡 Note: below example screenshots are taken from IntelliJ IDEA 2022.2 (Ultimate Edition) and Eclipse IDE 2022-06 (4.24.0) on Mac OS, if you use a different OS or software version, related function and process may be different.

Step by step guide

1. Install Checkstyle plugin

IntelliJ IDEA Version

  1. Go to IntelliJ IDEA -> Preferences -> Plugins, search for Checkstyle and install. image-20230202174455687

  2. Restart IDE if needed.

Eclipse Version

  1. Go to Help -> Eclipse Marketplace, search for Checkstyle and install. image-20230202182132538
  2. Restart IDE if needed.

Tons of error would be thrown if scan our code with the built-in Checkstyle configurations (Google and Sun version), so we need to link our customized HEA configuration into Checkstyle plugin.

Firstly you need to download HEA Checkstyle configuration from GitHub Repo, and put it on your local directory (/Users/zhochi/hea/hea_checks.xml in my case).

IntelliJ IDEA Version

  1. Go to IntelliJ IDEA -> Preferences -> Tools -> Checkstyle, on Configuration File section, click + button. image-20230202183440744
  2. Input Description, and select Use a local Checkstyle file, then choose previously download HEA Checkstyle configuration. image-20230202185251849
  3. Click Next -> Finish, you will see the configuration is added.

💡 By using local Checkstyle configuration, you need to update the file whenever there is a new release version.

To avoid such case, HEA team is now working on the remote Checkstyle configuration (http) solution.

Eclipse Version

  1. Go to Eclipse -> Preferences -> Checkstyle, on Global Check Configurations section, click New button. image-20230202190758069
  2. Select External Configuration File, Input Nme, and choose previously download HEA Checkstyle configuration. Click OK, you will see the configuration is added. image-20230202191024122
  3. Set newly added configuration as default image-20230202191322018

3. Run checks

IntelliJ IDEA Version

Go to Checkstyle section in IntelliJ main board, select newly added configuration and run the check, results will be listed. image-20230202190309230

Eclipse Version

Right click on the file to be checked, select Checkstyle -> Check Code with Checkstyle, after a while, the result will be listed under Markers -> Checkstyle Problem. image-20230202191628682

Reference

CheckStyle-IDEA
Creating a custom Checkstyle configuration