Skip to content

Commit 36f73b9

Browse files
committed
make sure metrics end up in report file and only for --xml-version=3
1 parent 5c8d8e1 commit 36f73b9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,12 @@ namespace {
285285
void reportMetrics()
286286
{
287287
if (!mFileMetrics.empty()) {
288-
std::cout << " <metrics>" << std::endl;
288+
auto &out = mErrorOutput ? *mErrorOutput : std::cerr;
289+
out << " <metrics>" << std::endl;
289290
for (const auto &metric : mFileMetrics) {
290-
reportOut(" " + metric);
291+
out << " " << metric << std::endl;
291292
}
292-
std::cout << " </metrics>" << std::endl;
293+
out << " </metrics>" << std::endl;
293294
}
294295
}
295296

@@ -504,7 +505,8 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
504505
stdLogger.writeCheckersReport(supprs);
505506

506507
if (settings.outputFormat == Settings::OutputFormat::xml) {
507-
stdLogger.reportMetrics();
508+
if (settings.xml_version == 3)
509+
stdLogger.reportMetrics();
508510
stdLogger.reportErr(ErrorMessage::getXMLFooter(settings.xml_version));
509511
}
510512

0 commit comments

Comments
 (0)