Skip to content

Commit 0c065ea

Browse files
committed
address sonar cloud
Signed-off-by: Nitish Bharambe <[email protected]>
1 parent e6728db commit 0c065ea

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,25 @@ ComponentConnections construct_components_connections(main_model_state_c auto co
213213
comp_conn.branch3_connected.resize(state.comp_topo->branch3_node_idx.size());
214214
comp_conn.branch3_phase_shift.resize(state.comp_topo->branch3_node_idx.size());
215215
comp_conn.source_connected.resize(state.comp_topo->source_node_idx.size());
216-
std::transform(state.components.template citer<Branch>().begin(), state.components.template citer<Branch>().end(),
217-
comp_conn.branch_connected.begin(), [](Branch const& branch) {
218-
return BranchConnected{static_cast<IntS>(branch.from_status()),
219-
static_cast<IntS>(branch.to_status())};
220-
});
221-
std::transform(state.components.template citer<Branch>().begin(), state.components.template citer<Branch>().end(),
222-
comp_conn.branch_phase_shift.begin(), [](Branch const& branch) { return branch.phase_shift(); });
223-
std::transform(state.components.template citer<Branch3>().begin(), state.components.template citer<Branch3>().end(),
224-
comp_conn.branch3_connected.begin(), [](Branch3 const& branch3) {
225-
return Branch3Connected{static_cast<IntS>(branch3.status_1()),
226-
static_cast<IntS>(branch3.status_2()),
227-
static_cast<IntS>(branch3.status_3())};
228-
});
229-
std::transform(state.components.template citer<Branch3>().begin(), state.components.template citer<Branch3>().end(),
230-
comp_conn.branch3_phase_shift.begin(), [](Branch3 const& branch3) { return branch3.phase_shift(); });
231-
std::transform(state.components.template citer<Source>().begin(), state.components.template citer<Source>().end(),
232-
comp_conn.source_connected.begin(), [](Source const& source) { return source.status(); });
216+
std::ranges::transform(
217+
state.components.template citer<Branch>(), comp_conn.branch_connected.begin(), [](Branch const& branch) {
218+
return BranchConnected{static_cast<IntS>(branch.from_status()), static_cast<IntS>(branch.to_status())};
219+
});
220+
221+
std::ranges::transform(state.components.template citer<Branch>(), comp_conn.branch_phase_shift.begin(),
222+
[](Branch const& branch) { return branch.phase_shift(); });
223+
224+
std::ranges::transform(
225+
state.components.template citer<Branch3>(), comp_conn.branch3_connected.begin(), [](Branch3 const& branch3) {
226+
return Branch3Connected{static_cast<IntS>(branch3.status_1()), static_cast<IntS>(branch3.status_2()),
227+
static_cast<IntS>(branch3.status_3())};
228+
});
229+
230+
std::ranges::transform(state.components.template citer<Branch3>(), comp_conn.branch3_phase_shift.begin(),
231+
[](Branch3 const& branch3) { return branch3.phase_shift(); });
232+
233+
std::ranges::transform(state.components.template citer<Source>(), comp_conn.source_connected.begin(),
234+
[](Source const& source) { return source.status(); });
233235
return comp_conn;
234236
}
235237

power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
637637
assert(construction_complete_);
638638
// clear old solvers
639639
reset_solvers();
640-
ComponentConnections comp_conn = main_core::construct_components_connections(state_);
640+
ComponentConnections const comp_conn = main_core::construct_components_connections(state_);
641641
// re build
642642
Topology topology{*state_.comp_topo, comp_conn};
643643
std::tie(state_.math_topology, state_.topo_comp_coup) = topology.build_topology();

0 commit comments

Comments
 (0)