Skip to content

Add pre-commit

Cristian Le requested to merge LecrisUT/octopus:pre-commit into main

Description

pre-commit is a useful tool for performing common code-checks and employ specific coding standards. Developers should be encouraged to install it locally and add it as commit-hook. This is easily performed via

# Made a dummy python project to install useful tools for developers. Currently only install pre-commit
$ pip install ./python[dev]
# This installs commit-hooks for pre-commit
$ pre-commit install

The standing issues should be merged before the user can use this commit-hook regularly. A separate MR will be open with the minor fixes.

In the meantime, to manually run it simply run

$ pre-commit run -a
# or for a specific check and/or file, e.g. `end-of-file-fixer` and `README` file
$ pre-commit run end-of-file-fixer --files README

This only affects developers, so it is safe to add as is. Currently the commit-hooks added are bare-bones, but an important one is included in the cmake PR that has already raised various issues through clang-tidy.

There is a Fortran formatter and linter (cphyc/fortran-linter) that would be useful to incorporate as soon as it becomes more modular (upstream issue).

Checklist

  • I have checked that my code follows the Octopus coding standards
  • I have added tests for all the new features added in this request.
Edited by Cristian Le

Merge request reports