:blue_book: The official home page for mobile-aware SWAM
The official home page for mobile-aware SWAM
SWAM project follows Google Style Guide for coding convention. A few rules might be ignored depending on modules. For the full list of ignored rules, please see the following link:
When you push your commits, ALWAYS run clang-format & cpplint to submit a commit with style change. If there is a change due to code style issues, make two separate commits: (Please do not include other codes’ style change in the same commit)
clang-format automatically formats your code. Please, refer to the options of Clang format style for more details.
$ sudo apt-cache search clang-format
$ sudo apt-get install -y clang-format-XX.XX
$ clang-format-XX.XX -i --style=File [my_source_code_file]
or
$ find . -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs clang-format-XX.XX -i -style=file $1
cpplint is a static C++ style checker following Google’s C++ style guide. cpplint for ROS modules is available at AuDri/ROS/catkin/style/cpplint.py.
$ python cpplint.py [file_path]
or
$ find . -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs python cpplint.py $1
We use yapf as a formatter for python files. It changes the python files according to the defined style in ~/.config/yapf/style file. We use pep 8. We use style config as below. You can use yapf with PIP.
$ sudo pip install --proxy=http://192.168.1.184:8080 yapf
$ vi ~/.config/yapf/style
[style]
based\_on\_style = pep8
indent\_width = 4
split\_before\_logical\_operator = true
$ yapf -i *.py
Pylint is a source code, bug and quality checker for the Python programming language. It follows the style recommended by PEP 8, the Python style guide. To check a python file with pylint:
$ sudo pip install --proxy=http://192.168.1.184:8080 pylint
$ cd ros_prj
$ cp ROS/catkin/style/.pylintrc ~/
$ pylint your_file.py
Then, modify incorrect statements that are checked by pylint before submitting your PR.