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 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 |
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-IDEA plugin in the settings.Tools -> Checkstyle, find Configuration File, and click Use a local Checkstyle file.fe/check/checkstyle/checkstyle.xml file in the project root directory.Checkstyle version 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:
Checkstyle for Java plugin.The auto-formatting feature of IDEA is recommended:
Preferences -> Editor -> Code Style -> Java.Import Scheme and select IntelliJ IDEA code style XML.build-support/IntelliJ-code-format.xml file in the project root directory.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:
| 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 |
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.