-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Create a clang-format config #3190
Comments
How about we do 88, like black in python. Python has more restriction with indentation (mandatory and 4 spaces) than C++ (we're using 2) and everyone enjoys black. It will cover that spike in the histogram.
I'm totally ok in dropping it. Have no real affection for it and it will always makes transitioning between other languages/projects (python, matlab, every other c++ project) and PCL a little less awkward than right now. |
For me, 100 chars is an upper bound because otherwise it's not possible to open 2 editors side by side and compare the code with ease (peek at headers/something else) on a laptop. For comparison: my IDE can show a maximum of 125 chars after all of the real-estate is taken over by other things floating left and right. Prefer any value which allows easy reading of code, looking at at least 2 files side-by-side and typical workflow requirements of the developers. The actual value doesn't matter much. I usually switch off namespace indentation because almost everything is in a namespace. No need to add unneeded white-space. Stuff I wish is in the style for a lot of code (since we are touching almost every line):
|
True, though on the other hand Python does not have horrible
👍
Same sentiment from my side.
I wouldn't be against. This brings another question though, positioning of |
I made the switch to the same (new line after functions, and before else; none otherwise). Gives visibility to functions, saves screen space.
For better visuals, I also use the lesser known properties
I made a push. Do check it out. It's a bit hard to see which lines were affected by column width. Maybe you have some sample files (based on the graph above) |
I have a strong preference against
The first item especially. Everything else, I don't really care. |
No issues. Personal config's are supposed to be very opinionated. |
Interesting combination, did not see it before.
I am also against, but not strong at all. My reason is that semantically asterisk is a part of type (
Ideally just eliminate all c casts :) |
Exactly.
I remember the moving least squares code to be somewhat messy. Also the infamous agast if-else blocks |
Looks tidy now :) @kunaltyagi Was this formatted with all your proposed options? In particular, you brought up
which I did not know about, so was curious to see in action. But the code does not seem to have one argument per line. |
No. This is the current |
I got some time so I pushed another branch: c88-binpack and a PR so that you can compare easily. |
Thanks. I think I like the readability of that binpack brings. Regarding 88... well, sometimes even the function name (qualified) does not fit in one line 😅
Given your arguments, I guess my 120 proposal is waaaay off the radar for you. So I'm not going to fight about this one 😄 |
Okay. Let's see if others like it too. 😄
That's my issue with namespaces (to a degree) and templates. We can consider
Or we can do a refactor. For classes with too many templates, we can separate the config into a traits struct. Combined with
For compatibility, there can be a shim class which is deprecated. Lot's of work, I don't recommend for anything except parts of the library which are unstable and need an emergency upgrade. Octree looks very stable and I'd stay away from this option. |
I'm ok with it. 👍 Everything else, it's a level of beautification I don't personally consider important. |
I'd like to propose a few more options controlling constructor initializer lists. PCL is not 100% consistent on this, but I think our style is to break the list one variable per line and put comma before: FooClass()
: vpx_(0)
, vpy_(0)
, vpz_(0)
, leaf_size_(0.005f)
, normalize_bins_(false)
, curv_threshold_(0.03f)
, cluster_tolerance_(leaf_size_ * 3)
, eps_angle_threshold_(0.125f)
, min_points_(50)
, radius_normals_(leaf_size_ * 3)
{
// implementation It's more readable (in a similar way to argument bin packing), it's easier to reorder, and yields smaller diffs on changes. Here are corresponding options:
I'm open for different indentations, though personally find it nice when commas are aligned with |
I agree with the proposal and don't have any preference regarding indentation. |
Did I miss anything? |
Not really. Take a look at PR for comparison and the code at branch code-style-draft One last (non-)question from my side though. Should I add the |
Thanks. I skimmed through (some of) the files and this looks good to me. I noticed an issue in "2d/convolution.h": We'll need to prevent I don't think we necessarily need a separate PR for the config. I'd add it as a separate commit to #3188. |
Wouldn't a better method would be
Sending an updated commit soon |
The directive approach is also possible, though I find POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::InterestPoint, //
(float, x, x) //
(float, y, y) //
(float, z, z) //
(float, strength, strength) //
) There is a practical plus to the |
We have #2376 that started to deal with this topic, however the discussion there lost focus. I propose to use this issue to discuss exclusively the style config (no CI, clang-tidy, strategies to enforce, etc).
Here is a tentative config file that was born out of #2376:
The biggest open question was the line width. Here is how the distribution of line lengths look like in cpp and h files in PCL right now (only lines over 10 columns are shown):
My proposal was 120, but Sergio was pushing towards a smaller number.
One other thought that I had is the "SpaceBeforeParens" rule. Do we want to keep it? We will be touching most lines because of namespace indentation anyway, so can as well drop this notorious space.
Any other ideas/concerns/opinions?
The text was updated successfully, but these errors were encountered: