Skip to content

Commit

Permalink
Fix critical complexity smell
Browse files Browse the repository at this point in the history
Signed-off-by: Sébastien LAIGRE <[email protected]>
  • Loading branch information
sebalaig authored and mathbagu committed Dec 6, 2021
1 parent db78e41 commit fdefa0c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/iidm/IdBasedBusRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ stdcxx::CReference<Bus> IdBasedBusRef::resolveByLevel(const Network& network, co
if (stdcxx::isInstanceOf<Bus>(identifiable.get())) {
const auto& bus = dynamic_cast<const Bus&>(identifiable.get());
if (level == TopologyLevel::BUS_BRANCH) {
for (const auto& terminal : bus.getConnectedTerminals()) {
if (terminal.getBusView().getBus()) {
return terminal.getBusView().getBus();
}
}
const auto& terminals = bus.getConnectedTerminals();
auto it = std::find_if(terminals.begin(), terminals.end(), [](const Terminal& terminal) {
return static_cast<bool>(terminal.getBusView().getBus());
});
return it != terminals.end() ? it->getBusView().getBus() : stdcxx::cref<Bus>();
}
return stdcxx::cref(bus);
}
Expand Down

0 comments on commit fdefa0c

Please sign in to comment.