CADET-Core icon indicating copy to clipboard operation
CADET-Core copied to clipboard

Automatic code formatting using pre-commit and clang-format

Open sleweke opened this issue 2 years ago • 5 comments
trafficstars

Enables support for pre-commit and clang-format. Code is automatically formatted before committing.

Options for clang-format are documented here. I used this online preview for various clang-format settings. I'm still not fully satisfied, but it's a start.

I'm not sure how this PR will impact other PRs and their "mergeability".

sleweke avatar Sep 05 '23 13:09 sleweke

This would fix #99.

sleweke-bayer avatar Sep 05 '23 14:09 sleweke-bayer

I like this! :)

schmoelder avatar Sep 09 '23 10:09 schmoelder

Thank you for your submission, we really appreciate it!

Like many open-source projects we ask that you sign our Contributor License Agreement before we can accept your contribution. To sign, please post two separate comments based on the following templates 👇

  1. Comment:

- [ ] The CADET maintainers know my real name.

At least one of the following two applies:

- [ ] The CADET maintainers know my current employer.

- [ ] I am *not* making this contribution on behalf of my current employer.

  1. Comment:
    I have read the CLA Document and I hereby sign the CLA.
    1 out of 2 committers have signed the CLA.
    :white_check_mark: (ronald-jaepel)[https://github.com/ronald-jaepel]
    :x: @sleweke
    You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

github-actions[bot] avatar Aug 26 '24 14:08 github-actions[bot]

I've updated the PR to the current master, updated clang and re-formatted everything to confirm nothing breaks.

The ExternalFunctionTemplate.cpp files are whitespace sensitive, so they can't be reformatted. This can be acchieved by renaming them to .cpp.in template "input" files, that are then treated properly by clang.

ronald-jaepel avatar Aug 26 '24 15:08 ronald-jaepel

To set up on windows:

  • activate proper python env (conda or venv)
  • pip install pre-commit
  • pre-commit.exe install in the source code folder

To process all files with the new pre-committ workflow:

  • pre-commit run --all-files

ronald-jaepel avatar Aug 26 '24 15:08 ronald-jaepel