Skip to content

Commit d2d6623

Browse files
committed
fixed #13388 - store active checkers in build dir [skip ci]
1 parent d1698b3 commit d2d6623

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ namespace {
311311
return mCtuInfo;
312312
}
313313

314+
void setActiveCheckers(std::set<std::string> activeCheckers) {
315+
mActiveCheckers = std::move(activeCheckers);
316+
}
317+
314318
private:
315319
/**
316320
* Information about progress is directed here. This should be
@@ -465,6 +469,20 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
465469
for (auto i = mFiles.cbegin(); i != mFiles.cend(); ++i)
466470
fileNames.emplace_back(i->path());
467471
AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, mFileSettings);
472+
473+
std::ifstream fout(Path::join(settings.buildDir, "checkers.txt"));
474+
if (fout.is_open())
475+
{
476+
std::set<std::string> activeCheckers;
477+
std::string line;
478+
// cppcheck-suppress accessMoved - FP
479+
while (std::getline(fout, line))
480+
{
481+
// cppcheck-suppress accessMoved - FP
482+
activeCheckers.emplace(std::move(line));
483+
}
484+
stdLogger.setActiveCheckers(std::move(activeCheckers));
485+
}
468486
}
469487

470488
if (!settings.checkersReportFilename.empty())
@@ -522,6 +540,15 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
522540

523541
void StdLogger::writeCheckersReport(const Suppressions& supprs)
524542
{
543+
if (!mSettings.buildDir.empty())
544+
{
545+
std::ofstream fout(Path::join(mSettings.buildDir, "checkers.txt"));
546+
for (const auto& c : mActiveCheckers)
547+
{
548+
fout << c << std::endl;
549+
}
550+
}
551+
525552
const bool summary = mSettings.safety || mSettings.severity.isEnabled(Severity::information);
526553
const bool xmlReport = mSettings.outputFormat == Settings::OutputFormat::xml && mSettings.xml_version == 3;
527554
const bool textReport = !mSettings.checkersReportFilename.empty();

0 commit comments

Comments
 (0)