Skip to content

Commit

Permalink
fix: bugprone-error
Browse files Browse the repository at this point in the history
Signed-off-by: kobayu858 <[email protected]>
  • Loading branch information
kobayu858 committed Dec 23, 2024
1 parent a88e90e commit 74fc864
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ void MrmHandler::publishHazardCmd()
HazardLightsCommand msg;

msg.stamp = this->now();
if (is_emergency_holding_) {
// turn hazard on during emergency holding
msg.command = HazardLightsCommand::ENABLE;
} 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 (
is_emergency_holding_ || // turn hazard on during emergency holding
(isEmergency() && // turn hazard on if emergency flag is true

Check warning on line 120 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

MrmHandler::publishHazardCmd has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
param_.turning_hazard_on.emergency) // turn hazard on if vehicle is in emergency state

Check warning on line 121 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp#L119-L121

Added lines #L119 - L121 were not covered by tests
) {
msg.command = HazardLightsCommand::ENABLE;
} else {
msg.command = HazardLightsCommand::NO_COMMAND;
Expand Down Expand Up @@ -185,12 +184,12 @@ void MrmHandler::operateMrm()
if (current_mrm_behavior == mrm_state_.behavior) {
return;
}
if (!requestMrmBehavior(mrm_state_.behavior, RequestType::CANCEL)) {
if (
!requestMrmBehavior(mrm_state_.behavior, RequestType::CANCEL) ||
!requestMrmBehavior(current_mrm_behavior, RequestType::CALL)) {

Check warning on line 189 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp#L188-L189

Added lines #L188 - L189 were not covered by tests
handleFailedRequest();
} else if (requestMrmBehavior(current_mrm_behavior, RequestType::CALL)) {
mrm_state_.behavior = current_mrm_behavior;
} else {
handleFailedRequest();
mrm_state_.behavior = current_mrm_behavior;

Check warning on line 192 in system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp

View check run for this annotation

Codecov / codecov/patch

system/mrm_handler/src/mrm_handler/mrm_handler_core.cpp#L192

Added line #L192 was not covered by tests
}
return;
}
Expand Down

0 comments on commit 74fc864

Please sign in to comment.