diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d3108765..25609055b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - Meaningless `location_index` provided in output for break steps (#877) - `max_travel_time` not accounted for with vehicle steps in solving mode (#954) - `max_travel_time` not accounted for in `RouteSplit` (#941) +- Address sonarcloud "bugs" reports (#984) ## [v1.13.0] - 2023-01-31 diff --git a/src/algorithms/munkres.cpp b/src/algorithms/munkres.cpp index 3b9c8a964..d31cd13e2 100644 --- a/src/algorithms/munkres.cpp +++ b/src/algorithms/munkres.cpp @@ -7,6 +7,7 @@ All rights reserved (see LICENSE). */ +#include #include #include #include @@ -115,15 +116,12 @@ minimum_weight_perfect_matching(const Matrix& m) { // Step 3. // First y in equality neighbors not in T_set. - Index chosen_y; - for (auto const& edge : alternating_tree) { - if (T_set.find(edge.first) == T_set.end()) { - // MUST happen before endge reaches the end of - // alternating_tree. - chosen_y = edge.first; - break; - } - } + const auto it = + std::ranges::find_if(alternating_tree, [&](const auto& edge) { + return T_set.find(edge.first) == T_set.end(); + }); + assert(it != alternating_tree.end()); + auto chosen_y = it->first; auto matching_y = matching_yx.find(chosen_y); if (matching_y != matching_yx.end()) { diff --git a/src/structures/vroom/input/input.cpp b/src/structures/vroom/input/input.cpp index 52fdda846..a4f24da87 100644 --- a/src/structures/vroom/input/input.cpp +++ b/src/structures/vroom/input/input.cpp @@ -47,7 +47,7 @@ void Input::set_geometry(bool geometry) { void Input::add_routing_wrapper(const std::string& profile) { #if !USE_ROUTING throw RoutingException("VROOM compiled without routing support."); -#endif +#else if (!_has_all_coordinates) { throw InputException("Missing coordinates for routing engine."); @@ -78,11 +78,11 @@ void Input::add_routing_wrapper(const std::string& profile) { } catch (const osrm::exception& e) { throw InputException("Invalid profile: " + profile); } + break; #else // Attempt to use libosrm while compiling without it. throw RoutingException("VROOM compiled without libosrm installed."); #endif - break; case ROUTER::ORS: { // Use ORS http wrapper. auto search = _servers.find(profile); @@ -102,6 +102,7 @@ void Input::add_routing_wrapper(const std::string& profile) { std::make_unique(profile, search->second); } break; } +#endif } void Input::check_job(Job& job) {