-
-
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
Indentation (tabs or spaces) #4810
Comments
I'm for staying with tabs, and use a length of 4:
|
I believe the convention used to specify a tab length of 8. |
Note: Github by default uses a tab size of 8 when you display a file in the web browser. We can fix this adding an |
There is another way, indenting by tabs and aligning by spaces. It's a bit complicated, but one can change the tab size without breaking alignments. |
I assume tabs + spaces for alignment is what's meant by the tab options. |
Are we still going to use .clang-format? (#4690) To be honest, I don't care whether it's tabs or spaces. I work a lot in upstream libraries and whatever you choose, I'll still going to have to edit my options to match the tabs/space flavour of that lib. I used to have an opinion but now I'm more leaning towards: "f it! let a formatter figure it out!" Which bring us back to .clang-format. :-) PS: I vote in favor for #4690 (whatever the settings are) |
8-space tabs. C++ is hard to read with small indents because of braces etc. So I prefer a width of 8. That being said, align with spaces. Tabs are for indents and indents only, that way people can change tab size and not screw up alignment throughout the project. |
I strongly prefer spaces for layout consistency but if the product is largely maintained by people using editors that don't detect spaces and switch automatically it would be a burden on those developers. What I believe is most important is that the main contributors to the codebase (e.g. past 3 years) come to a decision that works for them. When I say main contributors, I mean those that are actually typing large amounts of code (as opposed to people like myself that usually patch a few lines of the build system). A vote is nice, but this isn't a democracy. Those that code the most get to decide what the project switches to. |
Yes. |
I think 2 or 4 spaces is good enough and for tabs, people can set that to inserting "n amount of spaces" instead of tabs for the project for consistency. I think it's easier to detect and keep track of spaces than tabs extraneous tabs. |
@tresf You said that the main coders should vote. Should I look into the |
@darkmastermindz CPP is almost unreadable at 2 space tabs imo. |
Coders of the last 1.5 years with >=10 commits (run on master, but should include merged branches):
I can't see all votes anymore, so can you all please vote (again), commenting on this post? Sorry for the mentions on advance. Reminder:
|
It really doesn’t matter so long as we have a linter or clang-tidy or something that runs as part of the PR process. I’m all for any solution that just makes things consistent across the whole codebase. If some person is ready to fix up all the indentation to be consistent and add some linter/clang-tidy/whatever, let them do so using the rules of their preference. Effectively I’m in favor of “whoever does the work to achieve consistency gets to decide what the conventions ought to be”. Once you have some tool in place to enforce these conventions, it should become fairly trivial to change them after the fact anyway, so it’s not critical that you choose the “perfect” convention from the start. |
No, but it's courteous to ask though :) |
I have a couple PRs with >10 commits each and almost 2000 LOC, but they're not merged as I'm putting it off till 1.2 is out. Any objections if I vote as well? |
Sorry, I mean, everyone feeling as a "current coder" can/should vote. This was just to get the majority in. |
As long as there no hard feelings about the current way, I strongly believe it's best to stick to what we use at the moment, which is tabs for indentation and spaces for alignment. If done correctly, tab length doesn't matter. Changing all code to use spaces for indentation will touch almost every single line in our codebase. This will inevitably get us into a merge conflict hell, which won't exactly help our 60+ open PRs. As long as we don't have the people to handle all these and their potential merge conflicts, I'm concerned that with such an enormous change we'll be shooting ourselves in the foot. |
@lukas-w I don't agree. I feel any auto-formatting will kill the PRs regardless. I don't think the PRs can be saved persay. What's more important, I feel, is to have the big PRs merged prior to the style. For example, most files us |
Shouldn't auto-formatting both the feature and target branches lead to no merge issues? I.e. if you want to merge your branch and discover the target branch being formatted, just format your branch and then merge? |
I don't know if this will affect the project in any way, but this will destroy |
@JohannesLorenz probably worth testing out that theory. The issue with large commits isn't so much the differences but rather the timing of them. In my experience git often can't handle the timing of the changes properly even on small commits if the same lines are touched at different times. A test on one of the larger PRs would tell us for sure. |
I voted "Change tabs into spaces (length 4)". It's what we use at work and the advantage is that it looks the same everywhere. |
For what it's worth: |
Yes that would be best, I'm arguing that this is what we lack resources for though.
In this case, frankly I'd prefer not doing any auto-formatting at all, also because of the point @noahb01 made about |
git blame can ignore whitespace and code moved into the next line:
For indentation If anyone wants to change their vote based on that fact, go ahead. @tresf I regularly changed more than whitespace on two branches and merged them together, which always worked, I never got merge conflicts on those lines. What do you mean git "can't handle"? |
When git.does a rebase (requires for merging some PRs) it always struggles with modified lines, even minor modifications. If whitespace isn't a concern, great. In my experience it struggles -- even with with minor modifications -- when doing a rebase because it needs to rewrite history on a feature branch and aligning changes is messy. I'd rather not talk about it though. It can be tested and then there's no need for explaining. |
@JohannesLorenz Do you still want to keep this open? |
I'll close this, as we have agreed on one style (4 space-width tabs) and use it in the clang-format PR ( #4690 ). Thanks for the reminder. |
Looking at the current code base, indentation is made using tabs, which also conforms to our coding conventions. The conventions, however, don't name the length for each tab. You can usually check line breaks or constructor initializer lists to see what tab length was used in the past.
The most files seem to use 4, though.
Note: We can do automatic conversions using #4690 .
Please vote (multiple votes allowed):
The text was updated successfully, but these errors were encountered: