-
Notifications
You must be signed in to change notification settings - Fork 1k
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 .clang-format configuration file for source code formatting. #343
Conversation
Add .clang-format configuration file for source code formatting. Also run clang-format on the codebase.
I appreciate consistency, but massive reformatting is going to cause merge conflicts in open pull requests, such as migration to ARC, and will make it very hard for others' forks to merge back. |
Yes, but you agree it still needs to be done at some point? |
I think tabs to spaces can be done all at once now, because it's relatively easy to diff and merge with whitespace ignored. |
OK, feel free to go ahead and do that (for source files - xcodeproj and plists should keep tabs). After we merge pending pull requests we'll run clang-format. I did jump the gun a little here, sorry for that. |
If there was a way to have git update modified lines to match formatting rules…
|
@MaddTheSane I actually do something like that with Once you make changes you can apply formatting to entire file and then just stage the parts that are relevant. |
Regarding the clang options:
|
I'd just keep the C++ specific options for if we end up using any C++ code for some reason and/or if we get WinSparkle to merge with us. Clang is smart; it's not going to try to apply them to ObjC. :) |
Regarding MaxEmptyLinesToKeep — I thought 2 lines were used to separate In latest code examples (I've checked HealthKit ObjC example and Swift book) Apple uses "Attach" style. The Linux style is closer to what Sparkle does, and I'd be quite happy with that. |
Linux is probably closest to what most Objective-C codebases do, too. Never seen any codebase use two consecutive blank lines. |
OK, great. |
I've changed only the brace style. I've tried to use BasedOnStyle: WebKit to inherit most options and just override the difference, but by default it formats pointers differently than Sparkle codebase, and clang-format from Alcatraz doesn't recognize |
Yeah, it didn't recognize the PointerAlignment options for me either. |
I went through every option in http://clang.llvm.org/docs/ClangFormatStyleOptions.html and picked the ones that seemed most consistent and sane.
I set ColumnLimit to 0 for now ("none") but do we want to set a line length limit? 80? 100? I know some people are pretty pedantic about this - we especially are in the Qt project :) - but personally I don't mind.
After we agree on a style and merge this we can auto format the codebase (minus third party code like bsdiff). It really is horrendous!