Skip to content
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

Apply clang tidy fix to entire code base (Part 2) #1394

Merged
merged 18 commits into from
Mar 14, 2019

Conversation

RoboticsYY
Copy link
Contributor

@RoboticsYY RoboticsYY commented Mar 12, 2019

Description

Following up moveit#1366, this PR intends to enable the readability-identifier-naming clang-tidy fix to MoveIt code base. The commits are split for different variable cases and for easy web explorer loading. Please note:

  • For exceptions to method names: CartToJnt is preferred by KDL, which does not align with camelBack.
  • For exceptions to local variable names: Same name Qt component is declared in the class but not used.
  • For static const member variable names: the current .clang-tidy implements UPPER_CASE without a suffix _. If a suffix _ is preferred, readability-identifier-naming.ClassConstantSuffix is required in .clang-tidy.

Checklist

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

In general, I approve this PR. Changing case nicely exposed the wrong / unintended status for static / const of some variables. Could you, please, adapt these few variables?

To keep the current clean state also in future, I will enable the clang-tidy check for Travis.

@@ -208,12 +208,12 @@ void ChompTrajectory::fillInMinJerk()
{
double start_index = start_index_ - 1;
double end_index = end_index_ + 1;
double T[6]; // powers of the time duration
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to just rename T to t. Powers is a kind of misleading name here, but t[i] = t^i.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, I think t or time is a better name here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree powers is not a good name. But t is used in the following code block as //powers of the time index point, so I think maybe it's better to name T here as td and the following t as ti to distinguish them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed.

@@ -201,14 +201,14 @@ QWidget* EndEffectorsWidget::createEditWidget()
controls_layout->addWidget(spacer);

// Save
QPushButton* btn_save_ = new QPushButton("&Save", this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice cleanup!

@@ -1398,16 +1398,16 @@ void PlanningSceneMonitor::configureDefaultPadding()
}

// Ensure no leading slash creates a bad param server address
static const std::string robot_description =
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a reason for this variable to be static. This is local to this function, isn't it ?
Having it static introduces race conditions.
Other opinions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Making it static saves the modified description so you don't have to substring it each call. But agreed; this function shouldn't be called that much, making it static is overkill.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using a static variable here, also allows to use a single robot_description_ only, i.e. multiple instances of PSM cannot use different robot descriptions. I even consider this a bug, although it's very rare, that you have multiple robots in a single ROS environment..

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed a commit to fix this remaining issue.

@@ -59,29 +59,29 @@ class LinearPathSegment : public PathSegment
{
}

Eigen::VectorXd getConfig(double s) const
Eigen::VectorXd getConfig(double s) const override
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why these override issues were not caught by Travis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sure that clang-tidy related pkgs were cleaned up and reinstalled as it is in the Travis. But I'm not sure about the difference of the result, I will dig into that.

@rhaschke
Copy link
Contributor

@RoboticsYY, I just noticed that this PR comprises a merge commit from master to include latest changes.
Please try to rebase instead. PR branches should avoid merge commits.

@rhaschke rhaschke requested review from davetcoleman, v4hn and bmagyar and removed request for v4hn March 12, 2019 13:15
Copy link
Contributor

@BryceStevenWilley BryceStevenWilley left a comment

Choose a reason for hiding this comment

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

I also approve, with a few nits + @rhaschke's comments.

@@ -208,12 +208,12 @@ void ChompTrajectory::fillInMinJerk()
{
double start_index = start_index_ - 1;
double end_index = end_index_ + 1;
double T[6]; // powers of the time duration
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, I think t or time is a better name here.

@@ -1398,16 +1398,16 @@ void PlanningSceneMonitor::configureDefaultPadding()
}

// Ensure no leading slash creates a bad param server address
static const std::string robot_description =
Copy link
Contributor

Choose a reason for hiding this comment

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

Making it static saves the modified description so you don't have to substring it each call. But agreed; this function shouldn't be called that much, making it static is overkill.

@@ -373,33 +373,33 @@ static void wrap_robot_interface()
{
using namespace moveit;

bp::class_<RobotInterfacePython> RobotClass("RobotInterface", bp::init<std::string, bp::optional<std::string>>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here: it's defining a class, should probably stay stylized as a class name.

@RoboticsYY
Copy link
Contributor Author

Please try to rebase instead. PR branches should avoid merge commits.

Sorry for the mistake. The commit history has been cleaned up.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

I approve this in the present form. @davetcoleman, could you provide another timely review?
This PR deals with variable renaming and you are the one who nitpicks on variable naming usually 😉

@RoboticsYY RoboticsYY force-pushed the clang-tidy-fix branch 2 times, most recently from 79d8fa4 to 6304f11 Compare March 13, 2019 09:20
Copy link
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.

No variable names got shorter, which is all i care about. The longer variable names are a great improvement thanks!

@davetcoleman davetcoleman merged commit 129e8e9 into moveit:master Mar 14, 2019
@RoboticsYY RoboticsYY deleted the clang-tidy-fix branch March 15, 2019 01:37
v4hn pushed a commit to v4hn/moveit that referenced this pull request Mar 30, 2020
* Conform class name to `CamelCase`

* Conform member method name to `camelBack`

* Exceptions to method name

* Conform local variable name to `lower_case` part 1

* Conform local variable name to `lower_case` part 2

* Conform local variable name to `lower_case` part 3

* Conform local variable name to `lower_case` part 4

* Local static variable to `lower_case`

* Local variable manual fix

* Exceptions to local variable name

* Conform static const variable name to `UPPER_CASE`

* Conform global variable name to `UPPER_CASE`

* Conform static const member variable to `UPPER_CASE`

* clang-format

* Travis: mandatory clang-tidy-check

* Catch up most recent changes

* Update .clang-tidy

* fixup! Conform static const variable name to `UPPER_CASE`
v4hn pushed a commit to v4hn/moveit that referenced this pull request Mar 31, 2020
* Conform class name to `CamelCase`

* Conform member method name to `camelBack`

* Exceptions to method name

* Conform local variable name to `lower_case` part 1

* Conform local variable name to `lower_case` part 2

* Conform local variable name to `lower_case` part 3

* Conform local variable name to `lower_case` part 4

* Local static variable to `lower_case`

* Local variable manual fix

* Exceptions to local variable name

* Conform static const variable name to `UPPER_CASE`

* Conform global variable name to `UPPER_CASE`

* Conform static const member variable to `UPPER_CASE`

* clang-format

* Travis: mandatory clang-tidy-check

* Catch up most recent changes

* Update .clang-tidy

* fixup! Conform static const variable name to `UPPER_CASE`
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.

4 participants