Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13633 (safety: the xml version 3 report should show safety properties) #7298

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,15 @@ void StdLogger::writeCheckersReport(const Suppressions& supprs)

if (xmlReport) {
reportErr(" </errors>\n");
if (mSettings.safety)
reportErr(" <safety/>\n");
if (mSettings.inlineSuppressions)
reportErr(" <inline-suppr/>\n");
if (!suppressions.empty()) {
std::ostringstream suppressionsXml;
supprs.nomsg.dump(suppressionsXml);
reportErr(suppressionsXml.str());
}
reportErr(checkersReport.getXmlReport(mCriticalErrors));
}
}
Expand Down
16 changes: 16 additions & 0 deletions test/cli/premium_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,19 @@ def test_misra_c_builtin_style_checks(tmpdir):
assert exitcode == 0
assert 'id="unusedVariable"' in stderr
assert 'id="checkersReport"' not in stderr

exitcode, _, stderr = cppcheck(['--xml-version=3', test_file], cppcheck_exe=exe)
assert exitcode == 0
assert '<safety/>' in stderr

exitcode, _, stderr = cppcheck(['--xml-version=3', '--premium=safety-off', test_file], cppcheck_exe=exe)
assert exitcode == 0
assert '<safety/>' not in stderr

exitcode, _, stderr = cppcheck(['--xml-version=3', '--inline-suppr', test_file], cppcheck_exe=exe)
assert exitcode == 0
assert '<inline-suppr/>' in stderr

exitcode, _, stderr = cppcheck(['--xml-version=3', '--suppress=foo', test_file], cppcheck_exe=exe)
assert exitcode == 0
assert '<suppression errorId="foo" />' in stderr
Loading