Skip to content

Commit ed7257b

Browse files
committed
Fix: Reduce variable scope to resolve Codacy warnings (totalCost, added, found_e)
1 parent 929cfe1 commit ed7257b

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

include/contraction/linearContraction.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ class Pgr_linear {
107107
pgassert(v != w);
108108
pgassert(u != w);
109109

110-
E e, f;
111-
bool found_e = false, found_f = false;
112-
113110
if (graph.is_directed()) {
111+
E e, f;
112+
bool found_e = false, found_f = false;
114113
/*
115114
* u --> v --> w
116115
*/

src/cpp_common/undirectedNoCostBG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ UndirectedNoCostsBG::UndirectedNoCostsBG(const std::vector<Edge_bool_t> &edges)
4949
for (const auto edge : edges) {
5050
V v1 = get_boost_vertex(edge.source);
5151
V v2 = get_boost_vertex(edge.target);
52-
E e;
53-
bool added = false;
5452
if (edge.going) {
53+
E e;
54+
bool added = false;
5555
boost::tie(e, added) = boost::add_edge(v1, v2, graph);
5656
if (added) E_to_id.insert(std::pair<E, int64_t>(e, edge.id));
5757
}

src/trsp/trspHandler.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ void TrspHandler::explore(
232232
int64_t cur_node,
233233
const EdgeInfo cur_edge,
234234
bool isStart) {
235-
double totalCost = 0.0;
236-
237235
auto vecIndex = cur_edge.get_idx(isStart);
238236

239237
for (const auto &index : vecIndex) {
@@ -244,7 +242,7 @@ void TrspHandler::explore(
244242
edge, isStart);
245243

246244
if ((edge.startNode() == cur_node) && (edge.cost() >= 0.0)) {
247-
totalCost = get_tot_cost(
245+
double totalCost = get_tot_cost(
248246
edge.cost() + extra_cost,
249247
cur_edge.idx(),
250248
isStart);
@@ -260,7 +258,7 @@ void TrspHandler::explore(
260258
}
261259

262260
if ((edge.endNode() == cur_node) && (edge.r_cost() >= 0.0)) {
263-
totalCost = get_tot_cost(
261+
double totalCost = get_tot_cost(
264262
edge.r_cost() + extra_cost,
265263
cur_edge.idx(),
266264
isStart);

0 commit comments

Comments
 (0)