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

refactor(behavior_velocity_no_stopping_area_module): cppcheck warnings #6986

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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Tier IV, Inc.

Check notice on line 1 in planning/behavior_velocity_no_stopping_area_module/src/scene_no_stopping_area.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 6.67 to 6.44, 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 @@ -87,12 +87,8 @@
const LineString2d line{{p0.x, p0.y}, {p1.x, p1.y}};
std::vector<Point2d> collision_points;
bg::intersection(area_poly, line, collision_points);
if (collision_points.empty()) {
continue;
}
const double yaw = tier4_autoware_utils::calcAzimuthAngle(p0, p1);
veqcc marked this conversation as resolved.
Show resolved Hide resolved
if (!collision_points.empty()) {
geometry_msgs::msg::Point left_point;
const double yaw = tier4_autoware_utils::calcAzimuthAngle(p0, p1);
const double w = planner_data_->vehicle_info_.vehicle_width_m;
const double l = stop_line_margin;
stop_line.emplace_back(
Expand Down Expand Up @@ -306,7 +302,6 @@

const int num_ignore_nearest = 1; // Do not consider nearest lane polygon
size_t ego_area_start_idx = closest_idx + num_ignore_nearest;
size_t ego_area_end_idx = ego_area_start_idx;
// return if area size is not intentional
if (no_stopping_area_reg_elem_.noStoppingAreas().size() != 1) {
return ego_area;
Expand All @@ -330,7 +325,7 @@
}
double dist_from_area_sum = 0.0;
// decide end idx with extract distance
ego_area_end_idx = ego_area_start_idx;
size_t ego_area_end_idx = ego_area_start_idx;
for (size_t i = ego_area_start_idx; i < pp.size() - 1; ++i) {
dist_from_start_sum += tier4_autoware_utils::calcDistance2d(pp.at(i), pp.at(i - 1));
const auto & p = pp.at(i).point.pose.position;
Expand Down
Loading