CheckStyle Code Style Check and Formatting Configuration#
Add the CheckStyle plugin to IDEA to ensure that the code style of each contributor remains consistent, reducing unnecessary code modifications. This article mainly explains how to add the CheckStyle plugin in IDEA and import the provided checkstyle.xml
configuration.
Install CheckStyle-IDEA#
- Go to the IDEA plugin marketplace:
File | Settings | Plugins
; - Search for
CheckStyle-IDEA
, and click install.
Configure CheckStyle#
-
Go to CheckStyle configuration:
File | Settings | Other Settings | Checkstyle
; -
Click the add button in the configuration file, you can fill in the configuration description arbitrarily, select the existing checkstyle.xml, click next and finish;
-
Check the configuration file you just created.
Configure Editor#
-
Go to editor configuration:
File | Settings | Editor | Code Style
; -
Import the checkstyle.xml configuration:
- Select the existing checkstyle.xml configuration file, and click OK.
At this point, the configuration for the code style check tool and formatting is complete.