From 32f31dca42366067607969b4c32c8d75e2f71836 Mon Sep 17 00:00:00 2001 From: Rokus Ottervanger Date: Fri, 8 Apr 2022 11:07:22 +0200 Subject: [PATCH] refactor: limit scope of local variable and declare const --- diagnostic_aggregator/src/aggregator.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/diagnostic_aggregator/src/aggregator.cpp b/diagnostic_aggregator/src/aggregator.cpp index 23f97a1ea..b0d97c1f0 100644 --- a/diagnostic_aggregator/src/aggregator.cpp +++ b/diagnostic_aggregator/src/aggregator.cpp @@ -228,7 +228,6 @@ void Aggregator::publishData() diag_toplevel_state.level = -1; int min_level = 255; uint non_ok_status_depth = 0; - uint depth = 0; uint report_idx = 0; vector > processed; @@ -240,7 +239,7 @@ void Aggregator::publishData() { diag_array.status.push_back(*processed[i]); - depth = static_cast(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/')); + const uint depth = static_cast(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/')); if (processed[i]->level > diag_toplevel_state.level) { diag_toplevel_state.level = processed[i]->level; @@ -279,7 +278,7 @@ void Aggregator::publishData() { diag_array.status.push_back(*processed_other[i]); - depth = static_cast(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/')); + const uint depth = static_cast(std::count(processed[i]->name.begin(), processed[i]->name.end(), '/')); if (processed_other[i]->level > diag_toplevel_state.level) { diag_toplevel_state.level = processed_other[i]->level;