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(route_handler): query shoulder lane in getLaneletSequence() if only_route_lanes is false and the arg is shoulder type #6567

Merged
Changes from all 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
fix(route_handle): query shoulder lane in getLaneletSequence() if onl…
…y_route_lanes is false and the arg is shoulder

Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
  • Loading branch information
soblin committed Mar 7, 2024
commit a6508cc0c9f5f9fbfeb8ed275997e6b49a8a049e
16 changes: 13 additions & 3 deletions planning/route_handler/src/route_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021-2023 Tier IV, Inc.

Check notice on line 1 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1900 to 1910, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Code Duplication

reduced similar code in: RouteHandler::getLaneletSequence. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check notice on line 1 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 4.47 to 4.51, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -643,12 +643,22 @@
return lanelet_sequence;
}

lanelet::ConstLanelets lanelet_sequence_forward =
getLaneletSequenceAfter(lanelet, forward_distance, only_route_lanes);
const lanelet::ConstLanelets lanelet_sequence_forward = std::invoke([&]() {
if (only_route_lanes) {
return getLaneletSequenceAfter(lanelet, forward_distance, only_route_lanes);
} else if (lanelet::utils::contains(shoulder_lanelets_, lanelet)) {
return getShoulderLaneletSequenceAfter(lanelet, forward_distance);

Check warning on line 650 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

Codecov / codecov/patch

planning/route_handler/src/route_handler.cpp#L650

Added line #L650 was not covered by tests
}
return lanelet::ConstLanelets{};

Check warning on line 652 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

Codecov / codecov/patch

planning/route_handler/src/route_handler.cpp#L652

Added line #L652 was not covered by tests
});
const lanelet::ConstLanelets lanelet_sequence_backward = std::invoke([&]() {
const auto arc_coordinate = lanelet::utils::getArcCoordinates({lanelet}, current_pose);
if (arc_coordinate.length < backward_distance) {
return getLaneletSequenceUpTo(lanelet, backward_distance, only_route_lanes);
if (only_route_lanes) {
return getLaneletSequenceUpTo(lanelet, backward_distance, only_route_lanes);
} else if (lanelet::utils::contains(shoulder_lanelets_, lanelet)) {
return getShoulderLaneletSequenceUpTo(lanelet, backward_distance);

Check warning on line 660 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

Codecov / codecov/patch

planning/route_handler/src/route_handler.cpp#L660

Added line #L660 was not covered by tests
}

Check warning on line 661 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

RouteHandler::getLaneletSequence has a cyclomatic complexity of 12, 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.

Check notice on line 661 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ New issue: Bumpy Road Ahead

RouteHandler::getLaneletSequence has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
}
return lanelet::ConstLanelets{};
});
Expand Down
Loading