Skip to content

Improve clang format#1193

Merged
rhaschke merged 5 commits intomoveit:melodic-develfrom
ubi-agni:improve-clang-format
Nov 21, 2018
Merged

Improve clang format#1193
rhaschke merged 5 commits intomoveit:melodic-develfrom
ubi-agni:improve-clang-format

Conversation

@rhaschke
Copy link
Copy Markdown
Contributor

@rhaschke rhaschke commented Nov 12, 2018

This is an attempt to improve the results of clang-format. Particularly:

  • increase penalty to break literal strings
  • increase penalty to break before first argument in function calls
  • reduce penalty to put return type on its own line

I think the resulting code is much better readable.

addBackgroundJob(boost::bind(&MotionPlanningDisplay::publishInteractiveMarkers, this, false), "publishInteractiveMark"
"ers");
addBackgroundJob(boost::bind(&MotionPlanningDisplay::publishInteractiveMarkers, this, false),
"publishInteractiveMarkers");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting literal strings like this was awful.

@jonbinney
Copy link
Copy Markdown
Contributor

+1 for this change.

@rhaschke rhaschke force-pushed the improve-clang-format branch from 2293649 to 49d2ed0 Compare November 19, 2018 17:00
@rhaschke
Copy link
Copy Markdown
Contributor Author

Rebased / reapplied settings to resolve conflicts.

Copy link
Copy Markdown
Member

@davetcoleman davetcoleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this minor tweak is worth the code disruption of other PRs... some of the changes I like, but most are not any better and some are worse. I'm fine with being outvoted on this, however.

active_joint_model_vector_[i]->getVariableRandomPositionsNearBy(rng, values + active_joint_model_start_index_[i],
*active_joint_bounds[i],
near + active_joint_model_start_index_[i],
distance);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer the old version - this change is less readable IMO and adds another line.

active_joint_model_vector_[i]->getVariableRandomPositionsNearBy(rng, values + active_joint_model_start_index_[i],
*active_joint_bounds[i],
near + active_joint_model_start_index_[i],
distances[i]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@rhaschke
Copy link
Copy Markdown
Contributor Author

I agree that this PR should only be merged after other large pending PRs.
@davetcoleman, Obviously you don't mind to have a newline directly after the opening parenthesis of a function call. By reducing the penalty for this, we can easily get this behaviour back.
I think, the key contribution of this PR is to avoid breaking literal strings.

@rhaschke rhaschke force-pushed the improve-clang-format branch from 49d2ed0 to b8c27bc Compare November 20, 2018 19:37
@rhaschke
Copy link
Copy Markdown
Contributor Author

@davetcoleman Could you please have another look. I further tweaked the clang-format settings, such that the source lines you complained about are not touched anymore.
The reformatting only touches a few lines now. So there is no reason to hold this back anymore.

Copy link
Copy Markdown
Member

@davetcoleman davetcoleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does look better now!

@rhaschke rhaschke merged commit 4c2b4ba into moveit:melodic-devel Nov 21, 2018
@rhaschke rhaschke deleted the improve-clang-format branch November 21, 2018 07:17
@rhaschke rhaschke mentioned this pull request Nov 21, 2018
rhaschke added a commit that referenced this pull request Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants