Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic code formatting using pre-commit and clang-format #148

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sleweke
Copy link
Contributor

@sleweke sleweke commented Sep 5, 2023

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-bayer
Copy link
Contributor

This would fix #99.

@schmoelder
Copy link
Contributor

I like this! :)

@jbreue16 jbreue16 added this to the v5.0.0 "CADET-Core" milestone Aug 26, 2024
@ronald-jaepel ronald-jaepel linked an issue Aug 26, 2024 that may be closed by this pull request
sleweke and others added 4 commits August 26, 2024 16:56
Uses pre-commit and clang-format to automatically format code before it
is committed.
Ignores VS Code and clangd LSP directories.
Copy link

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.
    ✅ (ronald-jaepel)[https://github.com/ronald-jaepel]
    @sleweke
    You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@ronald-jaepel
Copy link
Collaborator

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

Use clang-format for formatting code
5 participants