MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / writeCheckersReport

Method writeCheckersReport

cli/cppcheckexecutor.cpp:502–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502void StdLogger::writeCheckersReport(const Suppressions& supprs)
503{
504 // TODO: only necessary when we actually issue a checkers report?
505 if (!mCheckersFile.empty())
506 {
507 std::ofstream fout(mCheckersFile);
508 for (const auto& c : mActiveCheckers)
509 {
510 fout << c << std::endl;
511 }
512 }
513
514 bool summary, xmlReport, textReport;
515
516 if (!mSettings.collectLogCheckers(&summary, &xmlReport, &textReport))
517 return;
518
519 CheckersReport checkersReport(mSettings, mActiveCheckers);
520
521 // TODO: include in summary boolean
522 const auto& suppressions = supprs.nomsg.getSuppressions();
523 const bool summarySuppressed = std::any_of(suppressions.cbegin(), suppressions.cend(), [](const SuppressionList::Suppression& s) {
524 return s.errorId == "checkersReport";
525 });
526
527 if (summary && !summarySuppressed) {
528 ErrorMessage msg;
529 msg.severity = Severity::information;
530 msg.id = "checkersReport";
531
532 const int activeCheckers = checkersReport.getActiveCheckersCount();
533 const int totalCheckers = checkersReport.getAllCheckersCount();
534
535 std::string what;
536 if (mCriticalErrors.empty())
537 what = std::to_string(activeCheckers) + "/" + std::to_string(totalCheckers);
538 else
539 what = "There was critical errors";
540 if (!xmlReport && !textReport)
541 what += " (use --checkers-report=<filename> to see details)";
542 msg.setmsg("Active checkers: " + what);
543
544 reportErr(msg);
545 }
546
547 if (textReport) {
548 std::ofstream fout(mSettings.checkersReportFilename);
549 if (fout.is_open())
550 fout << checkersReport.getReport(mCriticalErrors);
551 }
552
553 if (xmlReport) {
554 reportErr(" </errors>\n");
555 if (mSettings.safety)
556 reportErr(" <safety/>\n");
557 if (mSettings.inlineSuppressions)
558 reportErr(" <inline-suppr/>\n");
559 if (!suppressions.empty()) {

Callers 1

check_internalMethod · 0.80

Calls 10

collectLogCheckersMethod · 0.80
getSuppressionsMethod · 0.80
getAllCheckersCountMethod · 0.80
setmsgMethod · 0.80
getReportMethod · 0.80
getXmlReportMethod · 0.80
emptyMethod · 0.45
dumpMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected