-
Follow git naming conventions when creating branches and commit messages.
-
Pull Request Rules:
- Link to an Issue – Every pull request must be associated with a corresponding issue that explains the motivation for the change and the expected outcome.
- Provide a Summary – Include a comment summarizing the key changes in the pull request description. Highlight any major modifications or impacts.
- One Feature per Pull Request – Keep pull requests focused on a single feature, fix, or improvement to ensure clarity and easier review.
- Scientific citations - Fire research deals with real life or death risks; If your code involves scientific models or calculations, include citations in BibText format. More info Cell2Fire-W/docs/README.md
TL;DR: Install the clang-format linter and use it in your IDE or editor, it should automatically use the .clang-format file in the project root.
For C++ code, clang-format is used to ensure consistent code formatting according to the rules specified in the .clang-format file. Formatting details can be found in the documentation.
# basic example
# install
sudo apt install clang-format
# use
clang-format -i -style=file my-code.cpp
Some IDE or editor integrations are listed below. As a last resort, use a pre-commit hook!
- Install the
Clang-Formatextension - Add the following to your
settings.json:
{
"clang-format.executable": "/usr/bin/clang-format",
"clang-format.style": "file",
"editor.formatOnSave": true
}Requirements: Already installed CLion and have the appropiate .clang-format file in the project root.
CLion will automatically enable ClangFormat and apply the settings found in the file if it's under the project root.
To manually run the formatting, use ctrl + alt + shift + L.
You can also enable automatic formatting on save, go to Settings | Tools | Actions on save and enable "Reformat code".
You can find more information in the official CLion documentation.
Requirements: Already installed vim and ALE plugin
Add the following configuration to your .vimrc
" Enable ALE
let g:ale_linters = {
\ 'cpp': ['clang-format'],
\}
" Automatically fix files on save
let g:ale_fix_on_save = 1
" Specify the fixer to use for C++
let g:ale_fixers = {
\ 'cpp': ['clang-format'],
\}Notice: This is not needed for this project, as we already have a .clang-format file in the project root.
sudo apt install clang-format # install clang-format
clang-format -style=gnu -dump-config > .clang-format # create .clang-format settings file
vim .clang-format # modify .clang-format to your liking
clang-format -i -style=file my-code.cpp # format a file