Commented Out Code
ID |
html.commented_out_code |
Severity |
info |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Html |
Tags |
code-style |
Description
Reports HTML comments (<!-- … -→) that contain commented-out markup rather than prose. The
comment body is re-parsed as HTML and treated as markup when it yields two or more elements, or a
single element that carries attributes or has a matching closing tag.
Rationale
Commented-out markup is dead weight: it clutters the source, drifts out of sync with the live page,
and is preserved by version control anyway, so it should be deleted rather than left behind. A
comment that merely mentions a lone bare tag (for example <!-- see the <body> here -→) is not
flagged.
<!-- <div class="legacy-banner">Old promo</div> --> <!-- FLAW: commented-out markup -->
<!-- TODO: revisit the promo layout --> <!-- OK: prose -->