Skip to content

Commit 23dbb0f

Browse files
committed
htmlreport: fix HTML validation and table column counts
generated html reports were failing Nu Html Checker at https://validator.w3.org/ - Add space before checkbox attributes to comply with HTML5 standards. - Remove trailing slashes from elements to prevent parser warnings. - Correct colspan in summary and fileEntry tables from 5 to 6 to match header column count, preventing table validation warnings. Signed-off-by: Robin Getz <[email protected]>
1 parent d1e4660 commit 23dbb0f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

htmlreport/cppcheck-htmlreport

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def filter_button(enabled_filters, id, function):
412412
enabled = enabled_filters.get(id, False)
413413
if not id:
414414
id = 'None'
415-
return '\n <label class="checkBtn%s"><input type="checkbox" onclick="%s(this)" id="%s"%s/>%s</label>'\
415+
return '\n <label class="checkBtn%s"><input type="checkbox" onclick="%s(this)" id="%s" %s>%s</label>'\
416416
% (' disabled' if not enabled else '', function, id, 'checked' if enabled else 'disabled', id)
417417

418418
def filter_bar(enabled):
@@ -428,8 +428,8 @@ def filter_bar(enabled):
428428
, classification_bar
429429
,''.join([filter_button(enabled, tool, 'toggleTool') for tool in ['cppcheck', 'clang-tidy']])
430430
,'\n | '
431-
,'\n <label class="severityHeader">File: <input type="search" oninput="filterFile(this.value)"/></label>'
432-
,'\n <label class="severityHeader">Filter: <input type="search" oninput="filterText(this.value)"/></label>'
431+
,'\n <label class="severityHeader">File: <input type="search" oninput="filterFile(this.value)"></label>'
432+
,'\n <label class="severityHeader">Filter: <input type="search" oninput="filterText(this.value)"></label>'
433433
,'\n </div>\n'])
434434
def git_blame(errors, path, file, blame_options):
435435
last_line= errors[-1]['line']
@@ -837,8 +837,8 @@ def main() -> None:
837837
lexer = guess_lexer(content, stripnl=False)
838838
except ClassNotFound:
839839
sys.stderr.write("ERROR: Couldn't determine lexer for the file' " + source_filename + " '. Won't be able to syntax highlight this file.")
840-
output_file.write("\n <tr><td colspan=\"5\"> Could not generate content because pygments failed to determine the code type.</td></tr>")
841-
output_file.write("\n <tr><td colspan=\"5\"> Sorry about this.</td></tr>")
840+
output_file.write("\n <tr><td colspan=\"6\"> Could not generate content because pygments failed to determine the code type.</td></tr>")
841+
output_file.write("\n <tr><td colspan=\"6\"> Sorry about this.</td></tr>")
842842
continue
843843

844844
if options.source_encoding:
@@ -932,10 +932,10 @@ def main() -> None:
932932
htmlfile = data.get('htmlfile') if is_file else None
933933

934934
output_file.write("\n <tbody class=\"fileEntry\">")
935-
output_file.write("\n <tr><td colspan=\"5\">%s</td></tr>" % row_content)
935+
output_file.write("\n <tr><td colspan=\"6\">%s</td></tr>" % row_content)
936936

937937
if filename in decode_errors:
938-
output_file.write("\n <tr><td colspan=\"5\">Could not generated due to UnicodeDecodeError</td></tr>")
938+
output_file.write("\n <tr><td colspan=\"6\">Could not generated due to UnicodeDecodeError</td></tr>")
939939

940940
sorted_errors = sorted(data['errors'], key=lambda k: k['line'])
941941
blame_data = git_blame(sorted_errors, source_dir, filename, blame_options) if add_author_information else []

0 commit comments

Comments
 (0)