-
Notifications
You must be signed in to change notification settings - Fork 987
Format includes with clang-format #2795
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
base: master
Are you sure you want to change the base?
Conversation
|
We really need to get #2792 fixed so we can proceed with many other PRs.... |
bd00827 to
f73ec37
Compare
|
@v4hn I updated this with your suggested change in the PR to moveit2. |
f73ec37 to
741137e
Compare
rhaschke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this very much! Didn't know you can define include groups.
I learned this by poking around in some google code. |
741137e to
1335020
Compare
v4hn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pain to review (I managed a quarter before I gave up) and I'm sure we will notice unintuitive includes because of this patch in the future...
|
|
||
| #pragma once | ||
|
|
||
| #include <btBulletCollisionCommon.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This registers as a false-positive because bullet seems to use includes without prefix. Not much we can do about it I think, or do we want to add exceptions for specific header names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by false-positive here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this includes bullet headers, but it's grouped with standard headers because there is no prefix used in the include path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. However, before the bullet header was not grouped with anything else as well...
| #include <moveit/collision_detection_bullet/bullet_integration/contact_checker_common.h> | ||
| #include <boost/bind.hpp> | ||
|
|
||
| #include <bullet/btBulletCollisionCommon.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or, we just update all bullet includes to use the bullet/ prefix. Afaik the bullet tutorials use includes without prefix though.
| #include <boost/bind.hpp> | ||
|
|
||
| #include <ros/assert.h> | ||
| #include <ros/console.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect to see all ros/ includes before any other ros package.
More generally what I wanted was some sort of automated sorting of these. I might be weird in that I don't really care if they create some odd orders, just that there is some order. I want consistency in this and to stop getting review comments asking me to manually sort these. If anything I think we should adopt a simpler set of rules than these that are essentially: includes without / (mostly system includes) |
then we might as well go for simple alphabetical order altogether. include order should not matter aside from aesthetics. all the things I've pointed out so far are issues I would be inclined to change if I'd encounter them in source code.
If that's your only reason for trying to enforce a syntactic order on (semantic) includes I would say people should stop criticizing it unless there is no obvious order in the patch whatsoever. If people look at the autosorted includes later and have to adjust the clang-format file to get them in a meaningful order that's just what I would call "verschlimmbessern" in German... |
I don't get your criticism yet. Aren't you one of the guys who prefer sorting e.g. for package dependencies as well?
I agree that we should come up with a rule set to push the includes into a meaningful order before merging this PR. |
|
that statement was mainly a reply to
generally I think the approach is worthwhile, but it's a hassle to look through all the changes and judge them. Also I would expect another group for there is probably more to discuss in the rest of the patch... |
| #pragma once | ||
|
|
||
| #include <moveit/macros/class_forward.h> | ||
| #include <moveit/exceptions/exceptions.h> | ||
| #include <urdf/model.h> | ||
|
|
||
| #include <srdfdom/model.h> | ||
|
|
||
| #include <moveit/exceptions/exceptions.h> | ||
| #include <moveit/macros/class_forward.h> | ||
|
|
||
| // joint types | ||
| #include <moveit/robot_model/joint_model_group.h> | ||
| #include <iostream> | ||
|
|
||
| #include <Eigen/Geometry> | ||
|
|
||
| #include <moveit/robot_model/fixed_joint_model.h> | ||
| #include <moveit/robot_model/floating_joint_model.h> | ||
| #include <moveit/robot_model/joint_model_group.h> | ||
| #include <moveit/robot_model/planar_joint_model.h> | ||
| #include <moveit/robot_model/revolute_joint_model.h> | ||
| #include <moveit/robot_model/prismatic_joint_model.h> | ||
|
|
||
| #include <Eigen/Geometry> | ||
| #include <iostream> | ||
| #include <moveit/robot_model/revolute_joint_model.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the challenging things about this PR is that comments above blocks of includes essentially breaks the re-rodering. Here it re-ordered above and below the // joint types line as separate blocks. I've gone through and removed a bunch of these comments but here is one I forgot.
e1b0ec1 to
fdc3b1c
Compare
Description
@v4hn this was much easier in moveit than in moveit2... there were only 2 files I found with missing includes.
The gist of this change is that it formats the include lines so we can stop doing it manually. I don't like manually re-organizing include lines and think clang-format should do this for me. I hope you like this change as much as I do.
Here is the moveit2 PR this is a port of: moveit/moveit2#583