Web:ItemTagNotWithinContainerTagCheck - ul and li tags within repeater in asp.net framework

Enterprise Edition
Version 9.4 (build 54424)

In my asp.net framework 4.8 project, I have an aspx file with code similar to the following:

<asp:Repeater ID="TestRepeater" runat="server">

This code reports a BUG with the following rule:

"<li>" and "<dt>" item tags should be in "<ul>", "<ol>" or "<dl>" container tags

The output for this code above with 3 repeateritems would look like the following:


I believe this to be a false positive because in the example above, when the code renders my page, the ul tag in the header template will be rendered first and then the repeating item template will render the li tags (for however many repeateritems I have) and lastly the closing ul tage from the footer template. The output will be syntactically correct and wont break this rule.


I have encountered a couple similar problems with this rule in similar contexts:

1 - Razor (.cshtml) layout

This rule gets triggered in the following case:

In a layout page:


In a .cshtml page using said layout:

@section tabs {
<li>Tab heading</li>

Once composed the page is correctly structured, but Sonar cannot know this and reports an error.

2 - template HTML tag

The template HTML tag should be able to contain any other tag, since it too can be used for dynamic composition.
In particular we use Aurelia (v1) which mandates the template tag for its components.

This snippet triggers the rule:

    <li>A list element, which should be more complex than this example.</li>

Hello @jonathan.arrabito and @m-gallesio and thank you for your reports !

These are indeed some tricky FPs. I created a ticket where you can track our progress on this issue: [SONARHTML-159] Web:ItemTagNotWithinContainerTagCheck should be template-aware - SonarSource

There is no ETA yet, but we will let you know here when we tackle this. :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.