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

Applying Clang format #16

Merged
merged 7 commits into from
Apr 4, 2016
Merged

Applying Clang format #16

merged 7 commits into from
Apr 4, 2016

Conversation

norihiro-w
Copy link
Contributor

Same as we do in ogs6, I would like to suggest using clang format also in ogs5 except for external codes under ThirdParty dir. Having the consistent format is quite helpful, better code readability and less merge conflicts.

@norihiro-w norihiro-w force-pushed the clang-format branch 2 times, most recently from 55281fa to ebf7960 Compare March 4, 2016 12:10
@bilke
Copy link
Member

bilke commented Mar 10, 2016

I think we should wait with this until the changes from Kiel are merged (they are still working on it). Otherwise we have a hard time integrating them.

@norihiro-w
Copy link
Contributor Author

I don't think it makes merging harder, because they just need to apply clang-format to their code. Indeed it could make it even easier for them, because applying clang-format deletes all tiny differences between the versions, e.g. indentations, spaces at the end of lines, etc.

@bilke
Copy link
Member

bilke commented Mar 10, 2016

Good points indeed. 👍

@norihiro-w
Copy link
Contributor Author

TODO

  • 1. check format in travis for incoming PRs
  • 2. after approval, apply clang-format to the codes
  • 3. merge this PR

@norihiro-w norihiro-w force-pushed the clang-format branch 7 times, most recently from d31bcc8 to 99983a3 Compare March 11, 2016 13:22
@norihiro-w
Copy link
Contributor Author

@bilke I added coding style check in travis. can you please take a look again? If a PR doesn't follow the code style, "case=codingstyle " in the travis test should fail and its log includes a message ERROR: Found formatting errors!.

@norihiro-w norihiro-w force-pushed the clang-format branch 4 times, most recently from e146235 to d2ff3f0 Compare March 11, 2016 20:26
@bilke
Copy link
Member

bilke commented Mar 14, 2016

@norihiro-w Good work! For me it is good but hopefully it is not too strict for other people..

@@ -1,47 +1,61 @@
# Ubuntu 14.04 Trusty support
sudo: required
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment: Jobs requiring sudo are slower (see Boot Time) but otherwise you can not use apt-get install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately OpenMPI and PETSc installation requires apt-get install because the packages are not in their white list (as far as I tested)

@norihiro-w
Copy link
Contributor Author

Any other comments on this? I'll wait until Wednesdays and then go for merging.

@wenqing
Copy link
Member

wenqing commented Mar 14, 2016

How to apply the format? Seems not automatically.

@norihiro-w
Copy link
Contributor Author

Run clang-format -i -style=file will do it. There are also plugins for many IDEs including Visual studio.

Update: this is a complete shell script for Linux users
find . \( -name "*.h" -or -name "*.cpp" \) -print0 | xargs -0 clang-format -i -style=file

@wenqing
Copy link
Member

wenqing commented Mar 14, 2016

@norihiro-w I see. That's great.

@norihiro-w norihiro-w force-pushed the clang-format branch 2 times, most recently from 803a804 to 236c8a7 Compare March 20, 2016 13:46
@norihiro-w
Copy link
Contributor Author

UPDATE:

  • Modified the format style to minimize changes in current codes.
  • Added Linux and Windows versions of a batch script (under scripts/clang-format) applying clang-format to all source code files in OGS. Windows users can just double-click it to start the formatting.
  • TODO: Since version 3.8, clang-format automatically sorts the order of header includes, which doesn't really work for OGS codes because of comment lines in-between #includes. To deactivate this, a user should add SortIncludes: false in .clang-format.

@norihiro-w
Copy link
Contributor Author

About the formatting policy, I'm thinking in this way

  • In general we ask developers to apply clang-format or change the code by hand before they submit a PR. Travis will tell us if the changes follow the format or not. Note that the travis script checks only the codes being changed and ignores already committed codes.
  • For any urgent PR (e.g. bug fix), we will merge it even if their codes don't follow the format. Clang-format can be applied later.

@norihiro-w
Copy link
Contributor Author

will be merged after #33

@norihiro-w norihiro-w force-pushed the clang-format branch 2 times, most recently from 39a106a to f0d7697 Compare April 4, 2016 04:52
@norihiro-w norihiro-w merged commit baa2d16 into ufz:master Apr 4, 2016
@norihiro-w norihiro-w deleted the clang-format branch April 4, 2016 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants