diff --git a/plugins/cpp_metrics/service/src/cppmetricsservice.cpp b/plugins/cpp_metrics/service/src/cppmetricsservice.cpp index 929435995..4aa9b5c4c 100644 --- a/plugins/cpp_metrics/service/src/cppmetricsservice.cpp +++ b/plugins/cpp_metrics/service/src/cppmetricsservice.cpp @@ -149,8 +149,12 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath( { metricsAstNode.type = static_cast(metric.type); metricsAstNode.value = metric.value; + metrics.push_back(metricsAstNode); } + if (metrics.empty()) + continue; + CppAllMetricsAstNode nodeMetric; nodeMetric.id = std::to_string(node.id); nodeMetric.metrics = metrics; @@ -191,8 +195,12 @@ void CppMetricsServiceHandler::getCppFileMetricsForPath( { metricsModule.type = static_cast(metric.type); metricsModule.value = metric.value; + metrics.push_back(metricsModule); } + if (metrics.empty()) + continue; + CppAllMetricsModule nodeMetric; nodeMetric.id = std::to_string(file.id); nodeMetric.metrics = metrics;