Skip to content

Commit

Permalink
fix(utils): add guard
Browse files Browse the repository at this point in the history
Signed-off-by: satoshi-ota <[email protected]>
  • Loading branch information
satoshi-ota committed Oct 12, 2023
1 parent ee1574a commit add619c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ std::vector<lanelet::ConstPoint3d> getBoundWithIntersectionAreas(
const auto shared_point_itr_last =
std::find_if(expanded_bound.rbegin(), expanded_bound.rend(), [&](const auto & p) {
return std::any_of(
intersection_bound.begin(), intersection_bound.end(),
intersection_bound.rbegin(), intersection_bound.rend(),

Check warning on line 1734 in planning/behavior_path_planner/src/utils/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/utils/utils.cpp#L1734

Added line #L1734 was not covered by tests
[&](const auto & point) { return point.id() == p.id(); });
});

Expand All @@ -1757,6 +1757,13 @@ std::vector<lanelet::ConstPoint3d> getBoundWithIntersectionAreas(
continue;
}

// TODO(Satoshi OTA): remove this guard.
if (
std::distance(intersection_bound.begin(), trim_point_itr_last) <
std::distance(intersection_bound.begin(), trim_point_itr_init)) {
continue;

Check warning on line 1764 in planning/behavior_path_planner/src/utils/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/utils/utils.cpp#L1764

Added line #L1764 was not covered by tests
}

Check warning on line 1766 in planning/behavior_path_planner/src/utils/utils.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

getBoundWithIntersectionAreas increases in cyclomatic complexity from 28 to 30, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
std::vector<lanelet::ConstPoint3d> tmp_bound{};

tmp_bound.insert(tmp_bound.end(), expanded_bound.begin(), shared_point_itr_init);
Expand Down

0 comments on commit add619c

Please sign in to comment.