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

[CM] Linting if/else statements #1193

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,10 @@ bool ControllerManager::controller_sorting(
if (!((is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c)) &&
(is_controller_active(ctrl_b.c) || is_controller_inactive(ctrl_b.c))))
{
if (is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c)) return true;
if (is_controller_active(ctrl_a.c) || is_controller_inactive(ctrl_a.c))
{
return true;
}
return false;
}

Expand All @@ -2454,10 +2457,9 @@ bool ControllerManager::controller_sorting(
// The case of the controllers that don't have any command interfaces. For instance,
// joint_state_broadcaster
// If the controller b is also under the same condition, then maintain their initial order
if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable())
return false;
else
return true;
const auto command_interfaces_exist =
!ctrl_b.c->command_interface_configuration().names.empty();
return ctrl_b.c->is_chainable() && command_interfaces_exist;
}
else if (ctrl_b.c->command_interface_configuration().names.empty() || !ctrl_b.c->is_chainable())
{
Expand All @@ -2472,7 +2474,9 @@ bool ControllerManager::controller_sorting(
if (
std::find(following_ctrls.begin(), following_ctrls.end(), ctrl_b.info.name) !=
following_ctrls.end())
{
return true;
}
else
{
auto ctrl_a_preceding_ctrls = get_preceding_controller_names(ctrl_a.info.name, controllers);
Expand Down
Loading