After Code Developing#


We check the C++, R and Python format by CodeFactor. More specifically, the formatters and rules are:

Each pull request will be checked, and some recommendations will be given if not passed. But don't be worry about those complex rules, most of them can be formatted automatically by some tools.

Note that there may be few problems that the auto-fix tools can NOT deal with. In that situation, please update your pull request following the suggestions by CodeFactor.



Clang-Format is a powerful tool to format C/C++ code. You can install it quickly:

  • Linux: $ sudo apt install clang-format;

  • MacOS: $ brew install clang-format;

  • Windows: download it from LLVM;

with VS Code#

If you use Visual Studio Code for coding, an extension called C/C++ supports auto-fix by Clang-Format.

However, in order to adapt to our rules, you need to add some statements in setting.json (the configuration file for Visual Studio Code):

"C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Google, UseTab: Never, IndentWidth: 4, TabWidth: 4, ColumnLimit: 120, Standard: Cpp11}",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
// "editor.formatOnSave": true  // enable auto-fix after saving a file

After that, you can right-click on an C++ file and then click “Format Document”. That will be done.

with command line#

Besides, Clang-Format supports using directly in command line or based on a configuration file. You can check them here. The configuration is similar as above:

# `.clang-format` in the same directory of your C++ files
BasedOnStyle: Google
UseTab: Never
IndentWidth: 4
TabWidth: 4
ColumnLimit: 120
Standard: Cpp11

And then run $ clang-format -style=file some_code.cpp > some_code_formatted.cpp in command line. The formatted code is stored in some_code_formatted.cpp now.


Autopep8 can be used in formatting Python code. You can easily install it by $ pip install autopep8.

with VS Code#

Visual Studio Code can deal with Python auto-fix too, with Python extension.

There is no more steps to do. Right-click on an Python file and then click “Format Document”. That will be done.

with command line#

As we memtioned above, the default setting of Autopep8 is enough for us. Hence run $ autopep8 > and the formatted code is stored in now.