prisms-center / phaseField

PRISMS-PF: An Open-Source Phase-Field Modeling Framework
https://prisms-center.github.io/phaseField/
Other
229 stars 120 forks source link

Consider auto-formatting the source code #191

Closed stvdwtt closed 3 months ago

stvdwtt commented 1 year ago

The clang compiler has a standalone tool called "clang-format" that automatically formats C++ code according to user-specified options. The benefit is that this ensures consistency across a code base and eliminates the need for developers to think about formats. I've used this in a few different projects, and it works really well. Some code editors can automatically format code on save (e.g. VS Code, Atom) or it can be applied manually.

Here's some info on how to use it: https://www.clangpowertools.com/blog/getting-started-with-clang-format-style-options.html

To do this, the best way is to add a ".clangf-ormat" file in the root directory of the repository. An example of one is here: https://github.com/adamantine-sim/adamantine/blob/master/.clang-format

@david-montiel-t what do you think of moving PRISMS-PF to this? If you want, I'd be happy to make a style file and do the initial reformat of all of the files.

david-montiel-t commented 1 year ago

Thank you, Steve

I think it is a good idea. This would only change the style of the code files, right?

Yes, feel free to add the .clang-format file and reformat the code files accordingly.

stvdwtt commented 1 year ago

Sounds good. Do you want me to create a pull request into "master", or do you have a development branch for the next release?

david-montiel-t commented 1 year ago

You can do a PR into master.

david-montiel-t commented 3 months ago

Add a description of the clang-format we use somewhere in the documentation.