Skip to content

Commit b60118d

Browse files
authored
Fix #14689 (html report: Fix missing severity and classification bars) (#8456)
Fixes a bug introduced in #7994.
1 parent e5c4a73 commit b60118d

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

htmlreport/cppcheck-htmlreport

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ HTML_HEAD = """
278278
279279
updateFileRows();
280280
}
281-
281+
282282
function toggleClassification(cb) {
283283
cb.parentElement.classList.toggle("unchecked", !cb.checked);
284284
var elements = document.querySelectorAll(".class_" + cb.id);
@@ -289,7 +289,7 @@ HTML_HEAD = """
289289
290290
updateFileRows();
291291
}
292-
292+
293293
function toggleTool(cb) {
294294
cb.parentElement.classList.toggle("unchecked", !cb.checked);
295295
@@ -469,9 +469,9 @@ def filter_button(enabled_filters, id, function):
469469
def filter_bar(enabled):
470470
severity_bar = ''.join([filter_button(enabled, severity, 'toggleSeverity') for severity in ['error', 'warning', 'portability', 'performance', 'style', 'information']]) + '\n | '
471471
classification_bar = ''.join([filter_button(enabled, _class, 'toggleClassification') for _class in ['Mandatory', 'Required', 'Advisory', 'Document', 'Disapplied', 'L1','L2','L3','']]) + '\n | '
472-
if "checked/>" not in severity_bar:
472+
if "checked>" not in severity_bar:
473473
severity_bar = ''
474-
if "checked/>" not in classification_bar:
474+
if "checked>" not in classification_bar:
475475
classification_bar = ''
476476
return ''.join([
477477
' <div id="filters">\n'

test/tools/htmlreport/test_htmlreport.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ def testAddTimestamp(self):
107107

108108
output_directory.cleanup()
109109

110+
def testSeverityFilterBar(self):
111+
with runCheck(
112+
xml_filename=os.path.join(TEST_TOOLS_DIR, 'example.xml'),
113+
) as (report, output_directory):
114+
self.assertIn('onclick="toggleSeverity(this)"', report)
115+
output_directory.cleanup()
116+
110117

111118
@contextlib.contextmanager
112119
def runCheck(source_filename=None, xml_version='1', xml_filename=None, checkers_filename=None):

0 commit comments

Comments
 (0)