Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -311,6 +314,25 @@ namespace {
return mCtuInfo;
}

void readActiveCheckers() {
if (mCheckersFile.empty())
return;

std::ifstream fin(mCheckersFile);
if (fin.is_open())
{
std::set<std::string> 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
Expand Down Expand Up @@ -375,6 +397,11 @@ namespace {
* File metrics
*/
std::vector<std::string> mFileMetrics;

/**
* The file the cached active checkers are stored in
*/
std::string mCheckersFile;
};
}

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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();
Expand Down
Loading