Coding - RoBorregos/robocup-home GitHub Wiki
In order to have a maintainable and scalable project, it is necessary to follow certain coding standards and to include testing to our codebase. While at the beginning this may seem tedious, soon enough the benefits will become clear.
Coding style
Following a coding style not only makes the code cleaner and easier to understand, but it also lets anyone who's new to code at the same level than any other more experienced developer.
C++ style
Check RoBorrego's C++ Style Guide
Python style
First be sure to have Python2 installed and pip. This also works for Python3, however we need to remember that ROS 1 runs on Python2.
- Update Pip
pip2 install --upgrade pip
- The style we'll be following is PEP8 and the linter to help us will be Pylint. Also, in VSCode we'll be needing autopep8 to help us format the code accordingly.
pip2 install pep8
pip2 install pylint
pip2 install autopep8
- Once the previous packages have been installed, on your workspace edit the
.vscode/settings.json
by adding the following lines:
"python.pythonPath": "/your/own/python/directory",
"python.formatting.provider": "autopep8",
"python.linting.pylintEnabled": true
Note: If you wish to know the install location of python in ubuntu (pythonPath) just type which python
in the console.
- While the previous could be enough, to properly set a standard we'll be making use of the vscode extension pyright. Once installed, modify on your workspace the file
.vscode/settings.json
with the following lines:
"python.analysis.useLibraryCodeForTypes": true,
"python.analysis.typeCheckingMode":"strict"
Suggestions
If you strongly disagree with a rule from either styles, please contact the PM @paulvazbad to discuss such modification.
Testing
TODO: @paulvazbad & @tomvik