-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Display inline suppressions in XML output #7581
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,4 +456,44 @@ def test_unmatched_cfg(): | |
'{}cfg.c:14:0: information: Unmatched suppression: id [unmatchedSuppression]'.format(__proj_inline_suppres_path), | ||
] | ||
assert stdout == '' | ||
assert ret == 0, stdout | ||
assert ret == 0, stdout | ||
|
||
def test_xml_report_stdout(tmpdir): | ||
args = [ | ||
'-q', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember if some |
||
'--inline-suppr', | ||
'--xml-version=3', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest that |
||
f'{__proj_inline_suppres_path}template.cpp' | ||
] | ||
|
||
ret, stdout, stderr = cppcheck(args, cwd=__script_dir) | ||
lines = stderr.splitlines() | ||
|
||
assert ret == 0 | ||
assert stdout == '' | ||
|
||
assert ' <inline-suppressions>' in lines | ||
assert f' <suppression file="{__proj_inline_suppres_path}template.cpp" id="unusedFunction" lineNumber="9"/>' in lines | ||
assert ' </inline-suppressions>' in lines | ||
|
||
def test_xml_report_file(tmpdir): | ||
output_file = os.path.join(tmpdir, "results.xml") | ||
args = [ | ||
'-q', | ||
'--inline-suppr', | ||
'--xml-version=3', | ||
f'--output-file={output_file}', | ||
f'{__proj_inline_suppres_path}template.cpp' | ||
] | ||
|
||
ret, stdout, stderr = cppcheck(args, cwd=__script_dir) | ||
|
||
assert ret == 0 | ||
assert stdout == '' | ||
|
||
with open(output_file, 'r') as file: | ||
xml = file.read() | ||
|
||
assert ' <inline-suppressions>' in xml | ||
assert f' <suppression file="{__proj_inline_suppres_path}template.cpp" id="unusedFunction" lineNumber="9"/>' in xml | ||
assert ' </inline-suppressions>' in xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels like it might be possible to reuse the
SuppressionList::dump
.both inline and non-inline suppressions should be stored in the xml file and it's not required that they are stored separately.