Repository navigation
Clang tidy core (v2) - #880
davetcoleman merged 12 commits into
Conversation
|
You still have fixup! that need to be autosquashed into the history Although I will assume we will 'Squash and merge' so I suppose it does not matter. |
| @@ -0,0 +1,50 @@ | |||
| { | |||
There was a problem hiding this comment.
remove? i don't know what this is.
| @@ -0,0 +1,6 @@ | |||
| { | |||
There was a problem hiding this comment.
Mistaken IDE files. Removed.
There was a problem hiding this comment.
feel free to add these types of files to moveit's .gitignore
7c9fe42 to
0ce754b
Compare
|
Should be good now. Thanks, I just learned that fixup! is actually meant to be squashed, I just though it was a convention. |
v4hn
left a comment
There was a problem hiding this comment.
I looked through it once more and have the same comments on auto in range-based loops, but otherwise this looks very reasonable and nice to have.
| queue_change_event_(REMOVE, *it); | ||
| for (auto& event : removed) | ||
| queue_change_event_(REMOVE, event); | ||
| } |
There was a problem hiding this comment.
huge 👍 to removing iterators&index loops.
|
|
||
| bool satisfiesBounds(double margin = 0.0) const; | ||
| bool satisfiesBounds(const JointModelGroup* joint_group, double margin = 0.0) const; | ||
| bool satisfiesBounds(const JointModelGroup* group, double margin = 0.0) const; |
There was a problem hiding this comment.
If you change the names here anyway, wouldn't it make sense to streamline this file to JointModelGroup* jmg?
There was a problem hiding this comment.
This PR is mainly about automatic changes. I wouldn't mix in such manual changes. Actually I suggest to drop these variable renamings, because there not always satisfactory.
There was a problem hiding this comment.
i think we shouldn't be too picky about the power of clang-tidy and how much time it saves us from doing these optimizations and cleanup tasks manually...
There was a problem hiding this comment.
I agree with rhaschke, I'll drop the readability-inconsistent-declaration-parameter-name check for now, and make another PR that will manually resolve and use the 'better' name if it comes from the header (clang-tidy defaults to using the name used in the cpp file).
Once that is finished, we can add readability-inconsistent-declaration-parameter-name back to the checks to ensure no new changes are added that use different names.
| mjs.joint_names.clear(); | ||
| mjs.transforms.clear(); | ||
| for (std::size_t i = 0; i < js.size(); ++i) | ||
| for (auto model : js) |
There was a problem hiding this comment.
It took me a moment to understand that auto& would be redundant here because it's a primitive JointModel* ...
| for (std::map<std::string, AttachedBody*>::const_iterator it = attached_body_map_.begin(); | ||
| it != attached_body_map_.end(); ++it) | ||
| if (it->second->getAttachedLink() == lm) | ||
| for (const auto& attached : attached_body_map_) |
There was a problem hiding this comment.
Personally, I would still prefer to keep the type in range-based for loops, especially for maps.
In this case that would be
for(const std::pair<const std::string, AttachedBody*>& attached : attached_body_map_)
... or we stay with the original.
Otherwise, the (non-trivial) type of attached.second is given in the header file only (in the definition of attached_body_map_).
Unless you use an IDE that provides this information to you automatically, this is horrible to read.
But if multiple other maintainers agree we should prefer auto in loops, I will not insist.
There was a problem hiding this comment.
good point about attached.second being very hard to read, i'm ok with reverting this auto change
There was a problem hiding this comment.
That's true, I agree that auto in for loops is the most annoying use of auto.
Something to keep in mind is that clang-tidy doesn't gives you the option of automatically converting to for range loops without using auto. The good news is that it doesn't complain if you replace auto in an existing for loop, so manually adding the type like you suggested wouldn't be changed again.
I'll revert that commit, and in the future make a seperate PR that runs modernize-loop-convert and then follows up manually and fills in the actual types instead of auto.
| * @return | ||
| */ | ||
| IKSamplingPose(const kinematic_constraints::PositionConstraintPtr& pc); | ||
| IKSamplingPose(kinematic_constraints::PositionConstraintPtr pc); |
There was a problem hiding this comment.
I don't see why the const-ref is removed here. This actually avoids creating a new shared_ptr copy.
Such changes (clang-tidy:modernize-pass-by-value) should be reverted in my opinion.
There was a problem hiding this comment.
interesting, yes some of the results of that commit are surprising to me.
the std::move changes look like speed improving though.
i think we should remove that commit and discuss it in a separate PR
There was a problem hiding this comment.
Sounds good, I'll remove.
| * @param allowed_collision_type The allowed collision type will be filled here */ | ||
| bool getEntry(const std::string& name1, const std::string& name2, | ||
| AllowedCollision::Type& allowed_collision_type) const; | ||
| AllowedCollision::Type& allowed_collision) const; |
There was a problem hiding this comment.
The automatically suggested names are not always satisfactory. I suggest to drop/revert this commit for now and tackle this separately later.
There was a problem hiding this comment.
this is not clang-tidy's fault, its a bug by the original author who has the wrong name in the .cpp file.
i think we should make the variable names more consistent. but would you be happier if the "longer" or "more descriptive" variable name was kept instead of the one in the .cpp file?
There was a problem hiding this comment.
I know. clang-tidy cannot guess the "best" or "intended" name. That's why this type of cleanup requires manual revision and that's the reason I suggested to discuss it in a separate PR.
I don't think there are any relating to what y'all are doing in #882. There are some useful ones, see google-build-using-namespace and llvm-namespace-comment. |
0ce754b to
07159db
Compare
|
This PR needs to be merged in quick as it changes many files in a very safe way - it is auto-implementing best practices. I believe @BryceStevenWilley address @rhaschke's concerns in the last update of this PR, merging. |
* clang-tidy: modernize-redundant-void-arg * clang-tidy:modernize-use-nullptr * clang-tidy:modernize-use-default * clang-tidy:modernize-use-override * clang-tidy:readability-redundant-smartptr-get * clang-tidy:readability-simplify-boolean-expr * clang-tidy:readability-container-size-empty * clang-tidy:readability-named-parameter * Updated project-wide .clang-tidy with run checks. * One last run of clang-tidy to catch the most recent changes. * clang-format * Added .vscode to the gitignore.
|
Melodic: #911 |
* clang-tidy: modernize-redundant-void-arg * clang-tidy:modernize-use-nullptr * clang-tidy:modernize-use-default * clang-tidy:modernize-use-override * clang-tidy:readability-redundant-smartptr-get * clang-tidy:readability-simplify-boolean-expr * clang-tidy:readability-container-size-empty * clang-tidy:readability-named-parameter * Updated project-wide .clang-tidy with run checks. * One last run of clang-tidy to catch the most recent changes. * clang-format * Added .vscode to the gitignore.
* clang-tidy: modernize-redundant-void-arg * clang-tidy:modernize-use-nullptr * clang-tidy:modernize-use-default * clang-tidy:modernize-use-override * clang-tidy:readability-redundant-smartptr-get * clang-tidy:readability-simplify-boolean-expr * clang-tidy:readability-container-size-empty * clang-tidy:readability-named-parameter * Updated project-wide .clang-tidy with run checks. * One last run of clang-tidy to catch the most recent changes. * clang-format * Added .vscode to the gitignore.
Description
(A redo of #746, which had messy history)
Extended clang-tidy from collision_detection (#693) to the rest of moveit_core. Each commit is a specific clang-tidy check, it's probably easier to browse through each commit individually.
To keep this commit manageable, I only did clang-tidy checks that included automatic/simple fixes. In the future, we should look into enabling and fixing checks like cppcoreguidelines-* (http://releases.llvm.org/3.8.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html), as those are the most likely to result in fewer segfaults and silent bugs.
Checklist
Extended the tutorials / documentation, if necessary referenceInclude a screenshot if changing a GUIOptional: Created tests, which fail without this PR referenceOptional: Decide if this should be cherry-picked to other current ROS branches (Indigo, Jade, Kinetic)