2020-03-02 16:40:34 +08:00
|
|
|
# Coding standard
|
2018-01-18 01:11:57 +08:00
|
|
|
|
2020-09-06 19:43:19 +08:00
|
|
|
* [__General__](#general)
|
|
|
|
* [__Python__](#python)
|
|
|
|
* [__C++__](#c++)
|
|
|
|
|
2020-03-02 21:35:50 +08:00
|
|
|
---
|
2020-03-02 16:40:34 +08:00
|
|
|
## General
|
2018-01-18 01:11:57 +08:00
|
|
|
|
|
|
|
* Use spaces, not tabs.
|
|
|
|
* Avoid adding trailing whitespace as it creates noise in the diffs.
|
|
|
|
|
2020-03-02 21:35:50 +08:00
|
|
|
---
|
2020-03-02 16:40:34 +08:00
|
|
|
## Python
|
2018-01-18 01:11:57 +08:00
|
|
|
|
2018-12-22 02:50:54 +08:00
|
|
|
* Comments should not exceed 80 columns, code should not exceed 120 columns.
|
2020-03-23 22:19:22 +08:00
|
|
|
* All code must be compatible with Python 2.7 and 3.7.
|
2018-03-22 01:16:56 +08:00
|
|
|
* [Pylint][pylintlink] should not give any error or warning (few exceptions
|
2019-02-04 19:05:58 +08:00
|
|
|
apply with external classes like `numpy` and `pygame`, see our `.pylintrc`).
|
2018-03-22 01:16:56 +08:00
|
|
|
* Python code follows [PEP8 style guide][pep8link] (use `autopep8` whenever
|
|
|
|
possible).
|
|
|
|
|
|
|
|
[pylintlink]: https://www.pylint.org/
|
|
|
|
[pep8link]: https://www.python.org/dev/peps/pep-0008/
|
2018-01-18 01:11:57 +08:00
|
|
|
|
2020-03-02 21:35:50 +08:00
|
|
|
---
|
2020-03-02 16:40:34 +08:00
|
|
|
## C++
|
2018-01-18 01:11:57 +08:00
|
|
|
|
2018-12-22 02:50:54 +08:00
|
|
|
* Comments should not exceed 80 columns, code may exceed this limit a bit in
|
|
|
|
rare occasions if it results in clearer code.
|
2018-03-22 01:16:56 +08:00
|
|
|
* Compilation should not give any error or warning
|
2022-04-19 23:06:38 +08:00
|
|
|
(`clang++-8 -Wall -Wextra -std=C++14 -Wno-missing-braces`).
|
2019-01-26 23:10:52 +08:00
|
|
|
* The use of `throw` is forbidden, use `carla::throw_exception` instead.
|
2024-03-04 20:33:51 +08:00
|
|
|
* Unreal C++ code (CarlaUnreal and Carla plugin) follow the
|
2018-03-22 01:16:56 +08:00
|
|
|
[Unreal Engine's Coding Standard][ue4link] with the exception of using
|
|
|
|
spaces instead of tabs.
|
2018-07-29 01:29:31 +08:00
|
|
|
* LibCarla uses a variation of [Google's style guide][googlelink].
|
2019-01-27 00:27:14 +08:00
|
|
|
* Uses of `try-catch` blocks should be surrounded by
|
|
|
|
`#ifndef LIBCARLA_NO_EXCEPTIONS` if the code is used in the server-side.
|
2018-03-22 01:16:56 +08:00
|
|
|
|
|
|
|
[ue4link]: https://docs.unrealengine.com/latest/INT/Programming/Development/CodingStandard/
|
|
|
|
[googlelink]: https://google.github.io/styleguide/cppguide.html
|