Required development tools¶
Here, we list required tools for NEST development and explain their usage. The tools are mostly for formatting your code. Before you get started, please take a look at our detailed guidelines for C++ coding in NEST.
Development environment¶
We have provided an environment.yml file that contains all packages to do development in NEST, including the tools listed below.
Tooling¶
pre-commit¶
We use pre-commit to run Git hooks on every commit to identify simple issues such as
trailing whitespace or not complying with the required formatting. Our pre-commit
configuration is
specified in the .pre-commit-config.yaml
file.
To set up the Git hook scripts specified in .pre-commit-config.yaml
, run
pre-commit install
Note
If pre-commit
identifies formatting issues in the commited code, the pre-commit
Git hooks will reformat
the code. If code is reformatted, it will show up in your unstaged changes. Stage them and recommit to
successfully commit your code.
Black¶
We enforce PEP8 formatting of Python code by using the uncompromising Black formatter.
Black
is run automatically with pre-commit
.
Run Black
manually with
black .
isort¶
We use isort to sort imports in Python code.
isort
is run automatically with pre-commit
.
Run isort
manually with
isort --profile=black --thirdparty="nest" .
clang-format¶
We use clang-format to format C/C++ code.
Our clang-format
configuration is specified in the
.clang-format file.
clang-format
is run automatically with pre-commit
.
We supply the
build_support/format_all_c_c++_files.sh
shell script to run clang-format
manually:
./build_support/format_all_c_c++_files.sh [start folder, defaults to '$PWD']
Note
We use clang-format
version 17.0.4 in our CI. If your clang-format
executable is
not version 17, you need to specify an executable with version 17.0.4 explicitly with
the –clang-format option to ensure consistency with the NEST CI.
Local static analysis¶
We have several static code analyzers in the GitHub Actions CI. To run static code checks locally, please refer to the “run” lines in the GitHub Actions CI definition at https://github.com/nest/nest-simulator/blob/master/.github/workflows/nestbuildmatrix.yml.