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 committed 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.
Besides the automatic git commit hook, files can be formatted manually using pre-commit:
pre-commit run --all-filesformats all files andpre-commit run --files file1.cpp file2.cppformats only the specified files.
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 all C/C++ code. The configuration is defined in the .clang-format file corresponding to the version specified by CLANG_REQUIRE_VERSION in nestbuildmatrix.yml.
clang-format is run automatically via pre-commit.
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.