Format Code

    Doris Code Style is based on Google’s, makes a few changes. The customized .clang-format file is in the root dir of Doris. Now, .clang-format file only works on clang-format-8.0.1+.

    You should install clang-format, or you can use clang-format plugins which support by IDEs or Editors.

    Ubuntu: apt-get install clang-format

    Mac: brew install clang-format

    Centos 7:

    The version of clang-format installed by yum is too old. Compiling clang from source is recommended.

    Clion IDE supports the plugin “ClangFormat”, you can search in File->Setting->Plugins and download it. But the version is not match with clang-format. Judging from the options supported, the version is lower than clang-format-9.0.

    NOTE: Python3 is required to run the script.

    Clion

    If using the plugin ‘ClangFormat’ in Clion, choose Reformat Code or press the keyboard shortcut.

    VS Code

    VS Code needs install the extension ‘Clang-Format’, and specify the executable path of clang-format in settings.

    Open the vs code configuration page and search clang_format, fill the box as follows.