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

Add initial rules for running clang-format on the code base #409

Merged

Conversation

kdt3rd
Copy link
Contributor

@kdt3rd kdt3rd commented Jun 26, 2019

Signed-off-by: Kimball Thurston kdt3rd@gmail.com

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
@lgritz
Copy link
Contributor

lgritz commented Jun 26, 2019

LGTM, but it's hard to judge whether this is the right configuration without seeing what the diffs look like when this is applied to the project.

When I clang-format-ified OIIO, I went through a number of iterations of this config before it settled down, and only then did I make the big commits of all the source code post-reformatting.

@cary-ilm
Copy link
Member

cary-ilm commented Jun 26, 2019 via email

@cary-ilm
Copy link
Member

cary-ilm commented Jun 26, 2019 via email

@cary-ilm
Copy link
Member

cary-ilm commented Jun 26, 2019 via email

@meshula
Copy link
Contributor

meshula commented Jun 27, 2019

I once tried to figure out where the myFunc (int x) spacing convention came from as I felt Florian got it from somewhere else. I think it's from the old IRIS header files or something.

I agree that the sooner we can start iterating on this format file the better.

So, LGTM!

@lgritz
Copy link
Contributor

lgritz commented Jun 27, 2019

The space between function and paren was also my preferred way to do it, as far back as I can remember. But I did it inconsistently, for example preferring inst()->x rather than inst ().x which looked strange to me. I couldn't put that kind of nuance into clang-format's rules, so this ended up being one of those things I compromised on for the sake of uniformity, with the spaces jettisoned in the OIIO switch to clang-format. It was very hard to admit defeat on that front, but in retrospect I realize it just doesn't matter much in light of how much clang-format gives me.

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
@kdt3rd kdt3rd merged commit 969305c into AcademySoftwareFoundation:master Jun 27, 2019
@kdt3rd
Copy link
Contributor Author

kdt3rd commented Jun 27, 2019

I'm hoping the single largest change by bytes modified is actually the elimination of the mixed space and tab thing (replacing tabs with spaces, which means the code is indented consistently by all editors regardless of tab width setting). I realize this is an option to clang-format, but if we're going to do this, I'd like to make the code more readable by default regardless of editor config.

There are a large number of extra spaces at the end of lines, which also get cleaned up... ;-P

One thing which I can't decide how I feel is right now I have sorting of includes turned on (but not regrouping).

Anyway, I've updated the rules a bit to match more the prevalent style and added a script to do a find and run clang-format so you can judge what happens. Hooray for git checkout...

@kdt3rd kdt3rd deleted the add_clang_format_rules branch June 27, 2019 09:45
@meshula
Copy link
Contributor

meshula commented Jun 27, 2019

I jettisoned spaces before paren for a really simple reason. I have a habit of grepping for things that are called as functions, eg, search "foo(". With the space and no space if no parameter rule, the grep becomes complex, especially if foo() and foo(int bar) exist, because I have to grep "foo(" and also "foo (" to catch them all, or I have to write a regex to do something that would otherwise be "easy(".

@cary-ilm
Copy link
Member

cary-ilm commented Jun 27, 2019 via email

@meshula
Copy link
Contributor

meshula commented Jun 27, 2019

It's true that Windows based IDE's have supported regex for some years now. I just have to get used it ;)

@cary-ilm cary-ilm added this to the v2.4.0 milestone Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants