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_occlusion_spot_module): reduce cppcheck warning #6987

Conversation

veqcc
Copy link
Contributor

@veqcc veqcc commented May 12, 2024

Description

This is based on CppCheck warnings.

  1. remove unnecessary if branch
    30b90a3
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:91:9: style: Condition 'polys' is always true [knownConditionTrueFalse]
    if (polys) {
        ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:89:16: note: Assignment 'polys=true', assigned value is 1
  bool polys = true;
               ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:91:9: note: Condition 'polys' is always true
    if (polys) {
        ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:89:8: style: The scope of the variable 'polys' can be reduced. [variableScope]
  bool polys = true;
       ^
  1. add const for const variable
    b9fcb38
planning/behavior_velocity_occlusion_spot_module/src/debug.cpp:121:10: style: Variable 'possible_collisions' can be declared as reference to const [constVariableReference]
  auto & possible_collisions = debug_data.possible_collisions;
         ^
  1. remove redundant assignment
    06acd45
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:327:19: style: Assignment 'intensity=grid_utils::occlusion_cost_value::FREE_SPACE' is redundant with condition 'intensity==grid_utils::occlusion_cost_value::FREE_SPACE'. [duplicateConditionalAssign]
        intensity = grid_utils::occlusion_cost_value::FREE_SPACE;
                  ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:326:21: note: Condition 'intensity==grid_utils::occlusion_cost_value::FREE_SPACE'
      if (intensity == grid_utils::occlusion_cost_value::FREE_SPACE) {
                    ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:327:19: note: Assignment 'intensity=grid_utils::occlusion_cost_value::FREE_SPACE' is redundant
        intensity = grid_utils::occlusion_cost_value::FREE_SPACE;
                  ^
  1. remove redundant if branch
    d740ae0
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:351:39: style: Condition 'param.free_space_max<intensity' is always true [knownConditionTrueFalse]
      } else if (param.free_space_max < intensity && intensity < param.occupied_min) {
                                      ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:349:21: note: Assuming that condition 'intensity<=param.free_space_max' is not redundant
      if (intensity <= param.free_space_max) {
                    ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:351:39: note: Condition 'param.free_space_max<intensity' is always true
      } else if (param.free_space_max < intensity && intensity < param.occupied_min) {
                                      ^
planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:89:8: style: The scope of the variable 'polys' can be reduced. [variableScope]
  bool polys = true;
       ^
  1. underflow check
    da77325

  2. use const for const parameter
    eca35cd

planning/behavior_velocity_occlusion_spot_module/src/occlusion_spot_utils.cpp:429:87: style: Parameter 'debug_data' can be declared as reference to const [constParameterReference]
  const lanelet::ConstLanelet & path_lanelet, const PlannerParam & param, DebugData & debug_data)
                                                                                      ^

Question

If the first commit (about polys) is acceptable, then the function pointsToRays seems unnecessary anymore.
Do you think I should delete it too?

planning/behavior_velocity_occlusion_spot_module/src/grid_utils.cpp:46:0: style: The function 'pointsToRays' is never used. [unusedFunction]
std::vector<std::pair<grid_map::Position, grid_map::Position>> pointsToRays(
^

Tests performed

No

Effects on system behavior

Interface changes

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

veqcc added 6 commits May 12, 2024 13:54
Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
@github-actions github-actions bot added the component:planning Route planning, decision-making, and navigation. (auto-assigned) label May 12, 2024
@shmpwk
Copy link
Contributor

shmpwk commented May 13, 2024

@veqcc
Thank you for OSS contribution in holiday!
I agree to delete unnecessary if (polys) .
So could you delete pointsToRays you questioned?

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
@veqcc veqcc added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label May 13, 2024
@veqcc
Copy link
Contributor Author

veqcc commented May 14, 2024

Could anyone give it an approve?

Copy link
Contributor

@shmpwk shmpwk left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@shmpwk shmpwk merged commit a714f94 into autowarefoundation:main May 14, 2024
30 of 33 checks passed
@veqcc veqcc deleted the refactor/behavior_velocity_occlusion_spot_module branch May 14, 2024 05:15
vividf pushed a commit to vividf/autoware.universe that referenced this pull request May 16, 2024
…rning (autowarefoundation#6987)

* remove unnecessary if branch

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>

* add const for const variable

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>

* remove redundant assignment

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>

* remove redundant if branch

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>

* underflow check

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>

* use const for const parameter

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>

* style(pre-commit): autofix

* delete unnecessary pointsToRays function

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>

---------

Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: vividf <yihsiang.fang@tier4.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:planning Route planning, decision-making, and navigation. (auto-assigned) tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants