HTML: False positives with rule All HTML tags should be closed

  • versions used (SonarQube: 6.7.4 , language analyzer: htm: 3.1)

Hi, I wanted to report that this rule occasionally returns false positives.
In the following example, although as shown it contains all the closing tag, it fails indicating: The tag " " has no corresponding closing tag.

<div id="**" class="**">

The tag "div" has no corresponding closing tag.

	<s:form id="**" action="**" validate="false" Acceptcharset="UTF-8">
Replace all tab characters in this file by sequences of white-spaces.
The tag "s:form" has no corresponding closing tag.


		<div class="**">
		</div>

		<div class="**">
		</div>
		<%--  --%>
		<div id="**" style="display:none">
The tag "div" has no corresponding closing tag.

			<div class="****">
The tag "div" has no corresponding closing tag.

				<div class="**" style="width: 50%;">
The tag "div" has no corresponding closing tag.

					<input type="button" id=""

						onclick=""; return false;"

						onkeypress="lanzarClick(this); return false;"

						class="botonSubmit botonLimpiar" />

					<input type="button" id=""

						onclick="saveActivo(); return false;"

						onkeypress="lanzarClick(this); return false;"

						class="botonSubmit botonBuscar" />

				</div>

			</div>

		</div>

	</s:form>

	<div id="**" class="**"><span><s:text name="****" /></span></div>

</div>

Regards

Hey Frederic,

Are you sure the following bit of code is not causing the “false positive”? I’m not quite sure what it is supposed to do.

Regards,

Joël

Hi Joël,
Thank you for reviewing it,
<%-- --%> It is not part of the HTML that is giving me the false positive, it is sonarsource code that allows the code to look like this in the post.
I am getting the false positive each time a tag shows behind The tag “div” has no corresponding closing tag,even if it has the tag that closes at the end.

Regards

It seems to me that your html is broken in this part

<input type="button" id=""

						onclick=""; return false;"

the onclick attribute has additional " which is not matched. It seems that it confuses the parser and incorrect tags are reported as not closed.