Skip to content

fix(pid_longitudinal_controller): change pid structure with respect t…

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main) failed Dec 5, 2023 in 40s

CodeScene PR Check

❌ Code Health Quality Gates: FAILED

  • Declining Code Health: 5 findings(s) 🚩
  • Improving Code Health: 2 findings(s) βœ…
  • Affected Hotspots: 0 files(s) πŸ”₯

Recommended Review Level: Detailed -- Inspect the code that degrades in code health.
View detailed results in CodeScene

Details

🚩 Declining Code Health (highest to lowest):

  • Large Method pid_longitudinal_controller.cpp: diagnostic_updater_
  • Large Method pid_longitudinal_controller.cpp: PidLongitudinalController::paramCallback
  • Large Method test_longitudinal_controller_utils.cpp: TEST:TestLongitudinalControllerUtils:lerpTrajectoryPoint
  • Complex Method pid_longitudinal_controller.cpp: PidLongitudinalController::predictedStateAfterDelay
  • Complex Method pid_longitudinal_controller.cpp: PidLongitudinalController::getControlData

βœ… Improving Code Health:

  • Complex Method pid_longitudinal_controller.cpp: PidLongitudinalController::predictedVelocityInTargetPoint
  • Primitive Obsession longitudinal_controller_utils.cpp

Annotations

Check notice on line 1 in control/pid_longitudinal_controller/src/longitudinal_controller_utils.cpp

See this annotation in the file changed.

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

βœ… Getting better: Primitive Obsession

The ratio of primitive types in function arguments decreases from 67.86% to 63.64%, 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 notice on line 1035 in control/pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

See this annotation in the file changed.

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

βœ… No longer an issue: Complex Method

PidLongitudinalController::predictedVelocityInTargetPoint is no longer above the threshold for cyclomatic complexity. 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 1035 in control/pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

See this annotation in the file changed.

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

❌ New issue: Complex Method

PidLongitudinalController::predictedStateAfterDelay has a cyclomatic complexity of 10, 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 546 in control/pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

See this annotation in the file changed.

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

❌ New issue: Complex Method

PidLongitudinalController::getControlData 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 191 in control/pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

See this annotation in the file changed.

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

❌ Getting worse: Large Method

diagnostic_updater_ increases from 120 to 133 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check warning on line 377 in control/pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

See this annotation in the file changed.

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

❌ Getting worse: Large Method

PidLongitudinalController::paramCallback increases from 110 to 111 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check notice on line 1 in control/pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

See this annotation in the file changed.

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

β„Ή Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 4.29 to 4.57, 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 460 in control/pid_longitudinal_controller/test/test_longitudinal_controller_utils.cpp

See this annotation in the file changed.

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

❌ Getting worse: Large Method

TEST:TestLongitudinalControllerUtils:lerpTrajectoryPoint increases from 88 to 105 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check notice on line 63 in control/pid_longitudinal_controller/src/pid.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

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