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

[WIP] refactoring planning_evaluator #10310

Closed
wants to merge 6 commits into from

add unit test.

ed1fde7
Select commit
Loading
Failed to load commit list.
Closed

[WIP] refactoring planning_evaluator #10310

add unit test.
ed1fde7
Select commit
Loading
Failed to load commit list.
CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main) failed Mar 28, 2025 in 40s

CodeScene PR Check

Quality Gate Failed

Gates Failed
New code is healthy (1 new file with code health below 9.00)
Enforce critical code health rules (2 files with Bumpy Road Ahead, Deep, Nested Complexity)
Enforce advisory code health rules (4 files with Complex Method, Complex Conditional, Code Duplication, Primitive Obsession, Excess Number of Function Arguments)

Gates Passed
1 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
New code is healthy Violations Code Health Impact
planning_factor_accumulator.cpp 4 rules 10.00 → 8.61 Suppress
Enforce critical code health rules Violations Code Health Impact
planning_factor_accumulator.cpp 2 critical rules 10.00 → 8.61 Suppress
planning_evaluator_node.cpp 1 critical rule 8.50 → 7.91 Suppress
Enforce advisory code health rules Violations Code Health Impact
planning_factor_accumulator.cpp 2 advisory rules 10.00 → 8.61 Suppress
test_planning_evaluator_node.cpp 3 advisory rules 9.39 → 8.28 Suppress
planning_evaluator_node.cpp 2 advisory rules 8.50 → 7.91 Suppress
steer_accuulator.cpp 1 advisory rule 10.00 → 9.69 Suppress

Quality Gate Profile: Clean Code Collective
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

Details

🚩 Declining Code Health (highest to lowest):

  • Code Duplication test_planning_evaluator_node.cpp
  • Deep, Nested Complexity planning_factor_accumulator.cpp: PlanningFactorAccumulator::update
  • Complex Method planning_factor_accumulator.cpp: PlanningFactorAccumulator::update
  • Complex Conditional planning_factor_accumulator.cpp: PlanningFactorAccumulator::update
  • Complex Method steer_accuulator.cpp: SteerAccumulator::update
  • Complex Conditional planning_evaluator_node.cpp: PlanningEvaluatorNode::onPlanningFactors
  • Primitive Obsession test_planning_evaluator_node.cpp
  • Excess Number of Function Arguments test_planning_evaluator_node.cpp: publishEgoPose
  • Complex Method planning_evaluator_node.cpp: ~PlanningEvaluatorNode
  • Bumpy Road Ahead planning_factor_accumulator.cpp: PlanningFactorAccumulator::update
  • Bumpy Road Ahead planning_evaluator_node.cpp: ~PlanningEvaluatorNode

✅ Improving Code Health:

  • Overall Code Complexity planning_evaluator_node.cpp

Annotations

Check warning on line 104 in evaluator/autoware_planning_evaluator/src/metric_accumulators/planning_factor_accumulator.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

PlanningFactorAccumulator::update has a cyclomatic complexity of 13, 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 warning on line 74 in evaluator/autoware_planning_evaluator/src/metric_accumulators/planning_factor_accumulator.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

PlanningFactorAccumulator::update 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.

Check warning on line 104 in evaluator/autoware_planning_evaluator/src/metric_accumulators/planning_factor_accumulator.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Bumpy Road Ahead

PlanningFactorAccumulator::update 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.

Check warning on line 104 in evaluator/autoware_planning_evaluator/src/metric_accumulators/planning_factor_accumulator.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Deep, Nested Complexity

PlanningFactorAccumulator::update has a nested complexity depth of 4, threshold = 4. This function contains deeply nested logic such as if statements and/or loops. The deeper the nesting, the lower the code health.

Check warning on line 64 in evaluator/autoware_planning_evaluator/src/metric_accumulators/steer_accuulator.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

SteerAccumulator::update has a cyclomatic complexity of 9, 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 warning on line 159 in evaluator/autoware_planning_evaluator/src/planning_evaluator_node.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

~PlanningEvaluatorNode has a cyclomatic complexity of 9, 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 warning on line 461 in evaluator/autoware_planning_evaluator/src/planning_evaluator_node.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

PlanningEvaluatorNode::onPlanningFactors 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.

Check warning on line 159 in evaluator/autoware_planning_evaluator/src/planning_evaluator_node.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Bumpy Road Ahead

~PlanningEvaluatorNode 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.

Check notice on line 1 in evaluator/autoware_planning_evaluator/src/planning_evaluator_node.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 4.75 to 4.73, 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.

Check warning on line 1 in evaluator/autoware_planning_evaluator/test/test_planning_evaluator_node.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Code Duplication

introduced similar code in: TEST:EvalTest:TestAbnormalStopDecisionDistance,TEST:EvalTest:TestAbnormalStopDecisionDuration,TEST:EvalTest:TestSteeringChangeCount,TEST:EvalTest:TestSteeringChangeCountTimeOut and 2 more functions. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check warning on line 1 in evaluator/autoware_planning_evaluator/test/test_planning_evaluator_node.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Primitive Obsession

In this module, 60.0% of all function arguments are primitive types, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.

Check warning on line 238 in evaluator/autoware_planning_evaluator/test/test_planning_evaluator_node.cpp

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Excess Number of Function Arguments

publishEgoPose has 5 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.