Web:S5256 does not necessarily apply to layout pages

Version: SonarQube 9.8
Language: HTML (Razor)
Rule: Web:S5256 (tables should have headers)

This rule can be inaccurate when applied to layout pages:

<table>
    @RenderSection("tableContent")
</table>

This layout can be used like this:

@section tableContent {
    <tr><th>Heading</th></tr>
    <tr><td>Content</td></tr>
}

Of course the validity of the generated code depends on how the layout page is used.
This potentially applies to analogous rules in other languages / frameworks.

This is similar to the following reports:

I understand this might not be easy / desirable to fix and these cases can just be marked as ignored.

1 Like

Hi @m-gallesio,

Thanks for bringing this up.

Our intention was to analyze the HTML-like parts first, while ignoring the Razor specific features.

I’m sorry for the False Positives you are seeing. I created a ticket to track this issue: [SONARHTML-170] - Jira

Would you say you are getting useful findings in Razor templates or mostly False Positives like this?

I’m looking into this and would be happy to chat about it, let me know :slight_smile:

Best,
Gabriel

Right now most reports relate to the issues I outlined. Despite the false positives I prefer keeping rules on to keep the situation under control.

1 Like