Skip to content

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

Merged
davetcoleman merged 18 commits into
moveit:masterfrom
RoboticsYY:clang-tidy-fix
Mar 14, 2019
Merged

davetcoleman merged 18 commits into
moveit:masterfrom
RoboticsYY:clang-tidy-fix

Conversation

@RoboticsYY

@RoboticsYY RoboticsYY commented Mar 12, 2019 •

Copy link
Copy Markdown
Contributor

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

@rhaschke rhaschke left a comment

Copy link
Copy Markdown
Contributor

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.

{
double start_index = start_index_ - 1;
double end_index = end_index_ + 1;
double T[6]; // powers of the time duration

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed.

controls_layout->addWidget(spacer);

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice cleanup!

}

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 bmagyar, davetcoleman and v4hn and removed request for v4hn March 12, 2019 13:15

@BryceStevenWilley BryceStevenWilley left a comment

Copy link
Copy Markdown
Contributor

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.

{
double start_index = start_index_ - 1;
double end_index = end_index_ + 1;
double T[6]; // powers of the time duration

Copy link
Copy Markdown
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.

}

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

Copy link
Copy Markdown
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.

{
using namespace moveit;

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

Copy link
Copy Markdown
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
RoboticsYY force-pushed the clang-tidy-fix branch 3 times, most recently from 0775589 to 3851661 Compare March 13, 2019 07:02
@RoboticsYY

Copy link
Copy Markdown
Contributor Author

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

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

@rhaschke rhaschke left a comment

Copy link
Copy Markdown
Contributor

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

@davetcoleman davetcoleman left a comment

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.

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