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

fix(mrm_handler): fix bugprone-branch-clone #9729

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kobayu858
Copy link
Contributor

Description

This is a fix based on clang-tidy bugprone-branch-clone error.

/home/emb4/autoware/autoware/src/universe/autoware.universe/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp:118:30: error: repeated branch in conditional chain [bugprone-branch-clone,-warnings-as-errors]
  if (is_emergency_holding_) {
                             ^
/home/emb4/autoware/autoware/src/universe/autoware.universe/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp:121:4: note: end of the original
  } else if (isEmergency() && param_.turning_hazard_on.emergency) {
   ^
/home/emb4/autoware/autoware/src/universe/autoware.universe/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp:121:67: note: clone 1 starts here
  } else if (isEmergency() && param_.turning_hazard_on.emergency) {
                                                                  ^
/home/emb4/autoware/autoware/src/universe/autoware.universe/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp:188:72: error: repeated branch in conditional chain [bugprone-branch-clone,-warnings-as-errors]
    if (!requestMrmBehavior(mrm_state_.behavior, RequestType::CANCEL)) {
                                                                       ^
/home/emb4/autoware/autoware/src/universe/autoware.universe/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp:190:6: note: end of the original
    } else if (requestMrmBehavior(current_mrm_behavior, RequestType::CALL)) {
     ^
/home/emb4/autoware/autoware/src/universe/autoware.universe/system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp:192:12: note: clone 1 starts here
    } else {
           ^

Related links

Parent Issue:

  • Link

How was this PR tested?

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

Signed-off-by: kobayu858 <[email protected]>
@github-actions github-actions bot added the component:system System design and integration. (auto-assigned) label Dec 23, 2024
Copy link

github-actions bot commented Dec 23, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@kobayu858 kobayu858 added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Dec 23, 2024
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 29.74%. Comparing base (e5243e4) to head (cc46392).
Report is 46 commits behind head on main.

Files with missing lines Patch % Lines
...m/mrm_handler/src/mrm_handler/mrm_handler_core.cpp 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9729      +/-   ##
==========================================
- Coverage   29.74%   29.74%   -0.01%     
==========================================
  Files        1443     1443              
  Lines      108681   108684       +3     
  Branches    42663    42662       -1     
==========================================
- Hits        32330    32328       -2     
- Misses      73172    73177       +5     
  Partials     3179     3179              
Flag Coverage Δ *Carryforward flag
differential 0.00% <0.00%> (?)
total 29.74% <ø> (+<0.01%) ⬆️ Carriedforward from 74fc864

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -185,12 +184,12 @@ void MrmHandler::operateMrm()
if (current_mrm_behavior == mrm_state_.behavior) {
return;
}
if (!requestMrmBehavior(mrm_state_.behavior, RequestType::CANCEL)) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

The following is more straghtforward:

if (requestMrmBehavior(current_mrm_behavior, RequestType::CALL)) {
  mrm_state_.behavior = current_mrm_behavior;
} else {
  handleFailedRequest();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has been fixed. Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry but my suggestion will change the behavior, since requestMrmBehavior has side effects.
Please revert it.

} else if (isEmergency() && param_.turning_hazard_on.emergency) {
// turn hazard on if vehicle is in emergency state and
// turning hazard on if emergency flag is true
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

@mkuri @TetsuKawa
The original implementation looks wierd: Is the following correct?

if (param_.turning_hazard_on.emergency) {
  if (is_emergency_holding_ || isEmergency()) {
    msg.command = HazardLightsCommand::ENABLE;
  } else {
    msg.command = HazardLightsCommand::NO_COMMAND;
  }
} else {
  msg.command = HazardLightsCommand::NO_COMMAND;
}

Signed-off-by: kobayu858 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:system System design and integration. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
Status: To Triage
Development

Successfully merging this pull request may close these issues.

2 participants