diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 184cd00cd2f..5457621a0c5 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -259,6 +259,9 @@ namespace { if (!mSettings.outputFile.empty()) { mErrorOutput = new std::ofstream(settings.outputFile); } + if (!mSettings.buildDir.empty()) { + mCheckersFile = Path::join(settings.buildDir, "checkers.txt"); + } } ~StdLogger() override { @@ -311,6 +314,25 @@ namespace { return mCtuInfo; } + void readActiveCheckers() { + if (mCheckersFile.empty()) + return; + + std::ifstream fin(mCheckersFile); + if (fin.is_open()) + { + std::set activeCheckers; + std::string line; + // cppcheck-suppress accessMoved - FP + while (std::getline(fin, line)) + { + // cppcheck-suppress accessMoved - FP + activeCheckers.emplace(std::move(line)); + } + mActiveCheckers = std::move(activeCheckers); + } + } + private: /** * Information about progress is directed here. This should be @@ -375,6 +397,11 @@ namespace { * File metrics */ std::vector mFileMetrics; + + /** + * The file the cached active checkers are stored in + */ + std::string mCheckersFile; }; } @@ -465,6 +492,8 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup for (auto i = mFiles.cbegin(); i != mFiles.cend(); ++i) fileNames.emplace_back(i->path()); AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, mFileSettings); + + stdLogger.readActiveCheckers(); } if (!settings.checkersReportFilename.empty()) @@ -522,6 +551,15 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup void StdLogger::writeCheckersReport(const Suppressions& supprs) { + if (!mCheckersFile.empty()) + { + std::ofstream fout(mCheckersFile); + for (const auto& c : mActiveCheckers) + { + fout << c << std::endl; + } + } + const bool summary = mSettings.safety || mSettings.severity.isEnabled(Severity::information); const bool xmlReport = mSettings.outputFormat == Settings::OutputFormat::xml && mSettings.xml_version == 3; const bool textReport = !mSettings.checkersReportFilename.empty();