Coding standard
General
- Use spaces, not tabs.
- Avoid adding trailing whitespace as it creates noise in the diffs.
Python
- Comments should not exceed 80 columns, code should not exceed 120 columns.
- All code must be compatible with Python 2.7 and 3.7.
- Pylint should not give any error or warning (few exceptions
apply with external classes like
numpyandpygame, see our.pylintrc). - Python code follows PEP8 style guide (use
autopep8whenever possible).
C++
- Comments should not exceed 80 columns, code may exceed this limit a bit in rare occasions if it results in clearer code.
- Compilation should not give any error or warning
(
clang++-8 -Wall -Wextra -std=C++14 -Wno-missing-braces). - The use of
throwis forbidden, usecarla::throw_exceptioninstead. - Unreal C++ code (CarlaUE4 and Carla plugin) follow the Unreal Engine's Coding Standard with the exception of using spaces instead of tabs.
- LibCarla uses a variation of Google's style guide.
- Uses of
try-catchblocks should be surrounded by#ifndef LIBCARLA_NO_EXCEPTIONSif the code is used in the server-side.