Files
doris/docs/en/developer/developer-guide/java-format-code.md
wangyongfeng 2d39cffa5c [doc](website)Add Doris new official website code and documents (#9977)
In order to cooperate with Doris's successful graduation from Apache, the Doris official website also needs a new look
and more powerful feature, so we decided to redesign the Doris official website.
The code and documents of the new official website are included in this PR.

Since the new website is completely rewritten, the content and structure of the project are different from the previous one. 
In particular, the directory structure of documents has changed, and the number of documents is large, so the number of 
files in this PR is very large.

In the old website,all English documents are in the en/ directory, and Chinese documents in the zh-CN/ directory,
but in the new website,the documents are split into multiple directories according to the nav.
The document's directory structure changes as follows:
```
docs (old website)
|   |—— .vuepress (library)
|   |—— en
|   |   |—— admin-manual 
│   │   |—— advanced
|   |   |—— article
|   |   |—— benchmark
|   |   |—— case-user
|   |   |—— community
|   |   |—— data-operate
|   |   |—— data-table
|   |   |—— design
|   |   |—— developer-guide
|   |   |—— downloads
|   |   |—— ecosystem
|   |   |—— faq
|   |   |—— get-starting
|   |   |—— install
|   |   |—— sql-manual
|   |   |—— summary
|   |   |___ README.md
|   |—— zh-CN
...

docs (new website)
|   |—— .vuepress (library)
|   |—— en
|   |   |—— community (unchanged, community nav)
│   │   |—— developer (new directory, developer nav)
│   │   |   |—— design (moved from en/design)
│   │   |   |__ developer-guide (moved from en/developer-guide)
|   |   |—— docs (new directory, all children directories moved from en/, document nav)
│   │   |   |—— admin-manual 
│   │   |   |—— advanced
│   │   |   |—— benchmark
│   │   |   |—— data-operate
│   │   |   |—— data-table
│   │   |   |—— ecosystem
│   │   |   |—— faq
│   │   |   |—— get-starting
│   │   |   |—— install
│   │   |   |—— sql-manual
│   │   |   |—— summary
|   |   |—— downloads (unchanged, downloads nav)
|   |   |—— userCase (moved from en/case-user, user nav)
|   |   |___ README.md
|   |—— zh-CN
...
```
2022-06-08 17:45:12 +08:00

2.7 KiB

title, language
title language
Java Format Code en

Java Format Code

The formatting of the Java part of the code in Doris is usually done automatically by the IDE. Only the general format rules are listed here. For developer, you need to set the corresponding code styles in different IDEs according to the format rules.

Import Order

org.apache.doris
<blank line>
third party package
<blank line>
standard java package
<blank line>
  • Do not use import *
  • Do not use import static

Checkstyle Plugin

Now we have formatter-check in CI to check the code format.

IDEA

If you use IDEA to develop Java code, please install Checkstyle-IDEA plugin.

Setting the checkstyle.xml file in Tools->Checkstyle.

Click the plus sign under Configuration File, select Use a local Checkstyle file, and select the fe/check/checkstyle/checkstyle.xml file.

NOTE: Make sure that the version of Checkstyle is 9.3 or newer (the latest version is recommended).

You can use Checkstyle-IDEA plugin to check Checkstyle of your code real-time.

VS Code

If you use VS Code to develop Java code, please install Checkstyle for Java plugin, and config according to the document and the picture

IDEA

Auto format code

The automatic formatting function of IDEA is also recommended.

Go to Preferences->Editor->Code Style->Java click the config sign and select Import Scheme,select IntelliJ IDEA code style XML,and select the build-support/IntelliJ-code-format.xml file.

Auto rearrange code

Checkstyle will check declarations order according to Class and Interface Declarations .

After add the build-support/IntelliJ-code-format.xml file. Click Code/Rearrange Code to auto rearrange code.