Skip to content

Commit f5dbcfe

Browse files
committed
make sure metrics end up in report file and only for --xml-version=3
1 parent 486f060 commit f5dbcfe

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
@@ -289,11 +289,12 @@ namespace {
289289
void reportMetrics()
290290
{
291291
if (!mFileMetrics.empty()) {
292-
std::cout << " <metrics>" << std::endl;
292+
auto &out = mErrorOutput ? *mErrorOutput : std::cerr;
293+
out << " <metrics>" << std::endl;
293294
for (const auto &metric : mFileMetrics) {
294-
reportOut(" " + metric);
295+
out << " " << metric << std::endl;
295296
}
296-
std::cout << " </metrics>" << std::endl;
297+
out << " </metrics>" << std::endl;
297298
}
298299
}
299300

@@ -508,7 +509,8 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
508509
stdLogger.writeCheckersReport(supprs);
509510

510511
if (settings.outputFormat == Settings::OutputFormat::xml) {
511-
stdLogger.reportMetrics();
512+
if (settings.xml_version == 3)
513+
stdLogger.reportMetrics();
512514
stdLogger.reportErr(ErrorMessage::getXMLFooter(settings.xml_version));
513515
}
514516

0 commit comments

Comments
 (0)