Skip to content
Draft
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup

void StdLogger::writeCheckersReport(const Suppressions& supprs)
{
// TODO: only necessary when we actually issue a checkers report?
if (!mCheckersFile.empty())
{
std::ofstream fout(mCheckersFile);
Expand All @@ -510,11 +511,9 @@ void StdLogger::writeCheckersReport(const Suppressions& supprs)
}
}

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();
bool summary, xmlReport, textReport;

if (!summary && !xmlReport && !textReport)
if (!mSettings.collectLogCheckers(&summary, &xmlReport, &textReport))
return;

CheckersReport checkersReport(mSettings, mActiveCheckers);
Expand Down
2 changes: 1 addition & 1 deletion cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace {
void writeToPipe(PipeSignal type, const std::string &data) const
{
if (mDebug)
std::cout << "writeToPipe - " << static_cast<unsigned int>(type) << " - " << data << std::endl;
std::cout << "writeToPipe - " << static_cast<char>(type) << " - " << data << std::endl;

{
const auto t = static_cast<char>(type);
Expand Down
4 changes: 2 additions & 2 deletions lib/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ ErrorPath Check::getErrorPath(const Token* errtok, const ValueFlow::Value* value

void Check::logChecker(const char id[])
{
// TODO: only issue when we would actually use it later on
reportError(nullptr, Severity::internal, "logChecker", id);
if (!mSettings->buildDir.empty() || mSettings->collectLogCheckers())
reportError(nullptr, Severity::internal, "logChecker", id);
}

14 changes: 14 additions & 0 deletions lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,20 @@ class CPPCHECKLIB WARN_UNUSED Settings {

static bool unusedFunctionOnly();

bool collectLogCheckers(bool* summary = nullptr, bool* xmlReport = nullptr, bool* textReport = nullptr) const {
const bool s = safety || severity.isEnabled(Severity::information);
if (summary)
*summary = s;
const bool x = outputFormat == Settings::OutputFormat::xml && xml_version == 3;
if (xmlReport)
*xmlReport = x;
const bool t = !checkersReportFilename.empty();
if (textReport)
*textReport = t;

return s || x || t;
}

private:
static std::string parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity>, SimpleEnableGroup<Checks>> &groups);
std::string applyEnabled(const std::string &str, bool enable);
Expand Down
3 changes: 1 addition & 2 deletions test/cli/other_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4636,9 +4636,8 @@ def test_dui_include_absolute_missing(tmp_path): # #14675
]


@pytest.mark.xfail(strict=True) # TODO: should not report logChecker when not required
@pytest.mark.skipif(sys.platform == 'win32', reason="requires ProcessExecutor")
def test_ipc_log_checker(tmp_path):
def test_ipc(tmp_path):
test_file = tmp_path / 'test.c'
with open(test_file, "w") as f:
f.write('void f() {}')
Expand Down
Loading