Java Code Formatting Specification
The Java portion of Apache Doris code (mainly the FE module) is typically formatted automatically by the IDE. This document lists the general formatting rules and the corresponding configuration methods for different IDEs. The CI pipeline validates code formatting through formatter-check.
Import Order Rules
Import statements must be arranged in the following group order, with one blank line separating each group:
org.apache.doris
<blank line>
third party package
<blank line>
standard java package
<blank line>
Additional rules:
| Rule | Description |
|---|---|
No import * | Every class must be imported explicitly |
No import static | Static imports are not allowed |
Checkstyle Check at Compile Time
When compiling with maven, the Checkstyle check runs by default, which slightly slows down compilation. To skip the check, use the following command:
mvn clean install -DskipTests -Dcheckstyle.skip
The formatter-check in CI enforces code format validation. Skipping the check locally is only for development and debugging. Make sure the format complies before submitting a PR.
Checkstyle Plugin Configuration
Configure Checkstyle in IDEA
- Install the
Checkstyle-IDEAplugin in the settings. - Go to
Tools -> Checkstyle, findConfiguration File, and clickUse a local Checkstyle file. - Select the
fe/check/checkstyle/checkstyle.xmlfile in the project root directory. - Confirm that the
Checkstyleversion is 9.3 or above (the latest version is recommended).

Once configured, you can use the Checkstyle-IDEA plugin to run Checkstyle checks on the code:

Configure Checkstyle in VS Code
- Install the
Checkstyle for Javaplugin. - Complete the configuration by following the instructions and animations in the Java Linting official documentation.
IDEA Code Formatting
Auto-Formatting Configuration
The auto-formatting feature of IDEA is recommended:
- Go to
Preferences -> Editor -> Code Style -> Java. - Click the configuration icon's
Import Schemeand selectIntelliJ IDEA code style XML. - Select the
build-support/IntelliJ-code-format.xmlfile in the project root directory.
Rearrange Code
Checkstyle checks the order of code declarations according to Class and Interface Declarations.
After importing the build-support/IntelliJ-code-format.xml above, use Code/Rearrange Code to perform the sorting automatically:

Automatically Remove Unused Imports
| Purpose | Action |
|---|---|
| Remove unused imports only | Default shortcut CTRL + ALT + O |
| Automatically remove and reorder on save | Check Preferences -> Editor -> General -> Auto Import -> Optimize Imports on the Fly |
FAQ
Q: How do I troubleshoot a formatter-check failure in CI?
Run the check locally with IDEA or the Checkstyle plugin. Make sure the import order, naming conventions, and declaration order all comply with the requirements in fe/check/checkstyle/checkstyle.xml, then resubmit.
Q: Does skipping Checkstyle locally affect PR merging?
Yes. CI still runs formatter-check. The local -Dcheckstyle.skip option is only for speeding up development builds. The final code must pass Checkstyle.