Skip to content

Conversation

@Grufoony
Copy link
Collaborator

@Grufoony Grufoony commented Dec 2, 2025

Based on @filippodll request

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.27%. Comparing base (7eca02b) to head (87e2ce0).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
- Coverage   83.32%   83.27%   -0.05%     
==========================================
  Files          52       53       +1     
  Lines        5252     5275      +23     
  Branches      603      606       +3     
==========================================
+ Hits         4376     4393      +17     
- Misses        864      871       +7     
+ Partials       12       11       -1     
Flag Coverage Δ
unittests 83.27% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


/// @brief Update the paths of the itineraries based on the given weight function
void updatePaths();
void updatePaths(bool const throw_on_empty = true);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.8 rule Note

MISRA 17.8 rule

/// @brief Update the paths of the itineraries based on the given weight function
void updatePaths();
void updatePaths(bool const throw_on_empty = true);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 13.4 rule Note

MISRA 13.4 rule
pItinerary->id(),
pItinerary->destination());
emptyItineraries.push_back(pItinerary->id());
return;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
}
}
GIVEN("A disconnected graph") {
Street s1{0, std::make_pair(0, 1), 10.};

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note test

MISRA 12.3 rule
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the path validation functionality in the road dynamics system by making exception handling for empty paths configurable. The implementation allows users to either throw exceptions on invalid paths (default behavior) or silently remove problematic itineraries with warnings.

Key Changes:

  • Added a throw_on_empty parameter to updatePaths() to control behavior when itineraries have no valid paths
  • Refactored Itinerary getters to be inlined for better performance
  • Added comprehensive test coverage for both throwing and non-throwing scenarios

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/dsf/mobility/RoadDynamics.hpp Added throw_on_empty parameter to updatePaths(), implemented conditional error handling and automatic removal of invalid itineraries
src/dsf/mobility/Itinerary.hpp Inlined simple getter methods (id(), destination(), path()) and added new empty() method for path validation
src/dsf/mobility/Itinerary.cpp Removed function definitions that were moved inline to the header
src/dsf/bindings.cpp Updated Python bindings to expose the new throw_on_empty parameter with proper default value
test/mobility/Test_dynamics.cpp Added test cases for both throw_on_empty=true and throw_on_empty=false scenarios, commented out debug logging

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1274 to +1275
m_destinationNodes.erase(destination);
m_originNodes.erase(destination);
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

Multiple itineraries can share the same destination node. Unconditionally erasing destination from m_destinationNodes and m_originNodes when removing an itinerary will incorrectly remove these nodes even if other valid itineraries still use them as destinations.

Consider checking if any remaining itineraries use the same destination before removing it from these maps, or maintain reference counts for shared destinations.

Suggested change
m_destinationNodes.erase(destination);
m_originNodes.erase(destination);
// Only erase destination/origin nodes if no other itinerary uses this destination
bool destinationStillUsed = std::any_of(
m_itineraries.begin(), m_itineraries.end(),
[id, destination](const auto& pair) {
return pair.first != id && pair.second->destination() == destination;
});
if (!destinationStillUsed) {
m_destinationNodes.erase(destination);
m_originNodes.erase(destination);
}

Copilot uses AI. Check for mistakes.
@Grufoony Grufoony changed the title Path throws Add throw_on_empty param to updatePaths Dec 2, 2025
@Grufoony Grufoony merged commit 292021f into main Dec 2, 2025
42 of 43 checks passed
@Grufoony Grufoony deleted the pathThrows branch December 2, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants