Skip to content
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
3 changes: 3 additions & 0 deletions htmlreport/cppcheck-htmlreport
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ class CppCheckHandler(XmlContentHandler):
error = self.errors[-1]
locations = error['locations']
file = attributes['file']
# Cppcheck Premium reports license messages with this pseudo file name
if file == 'Cppcheck Premium':
file = ''
line = int(attributes['line'])
if not locations:
error['file'] = file
Expand Down
19 changes: 19 additions & 0 deletions test/tools/htmlreport/test_htmlreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ def testEscape(self):

output_directory.cleanup()

def testPremiumLicenseMessage(self):
with tempfile.TemporaryDirectory() as tmpdir:
xml_filename = os.path.join(tmpdir, 'premium.xml')
with open(xml_filename, 'w') as f:
f.write('<?xml version="1.0" encoding="UTF-8"?>\n'
'<results version="2"><cppcheck version="2.18"/><errors>\n'
'<error id="premium-licenseExpiresSoon" severity="information" msg="license will expire" verbose="license will expire">\n'
'<location file="Cppcheck Premium" line="0" column="0"/>\n'
'</error>\n'
'</errors></results>\n')
output_directory = os.path.join(tmpdir, 'out')
p = subprocess.run([*HTML_REPORT_BIN, '--file=' + xml_filename, '--report-dir=' + output_directory],
capture_output=True, text=True, check=True)
self.assertNotIn('not found', p.stderr)
with open(os.path.join(output_directory, 'index.html')) as index_file:
report = index_file.read()
self.assertIn('license will expire', report)
self.assertNotIn('0.html#line-0', report)


@contextlib.contextmanager
def runCheck(source_filename=None, xml_version='1', xml_filename=None, checkers_filename=None):
Expand Down
Loading