You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
S5256 (tables should have headers) raises false positives on Razor layout pages, where the <table> sits in the layout and the <th> rows are injected by @RenderBody, @RenderSection, or @Html.Partial/@Html.RenderPartial from a child view. This PR adds a symmetric exemption to the existing Thymeleaf fragment-insertion logic.
Changes
TableWithoutHeaderCheck.startDocument pre-scans .cshtml/.vbhtml files for TextNodes containing Razor fragment-rendering expressions (@RenderBody, @RenderSection, @RenderPage, @Html.(Render)?Partial(Async)?, with or without await); every <table> ancestor of such a node is exempted from S5256.
Reusable helpers added to Helpers: isRazorFile(HtmlSourceCode) and containsRazorFragmentRendering(String).
New unit tests + .cshtml / .vbhtml / .html fixtures covering the FP cases and the non-suppression invariants (real bug in a Razor file, Razor-looking text in a plain .html file).
Agentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action.
Functional validation bundle: see attached SONARHTML-170-fv.zip below.
Unzip and run ./run.sh — it compiles a small standalone reproducer against the bundled patched plugin JAR and applies, for each fixture, both the legacy and the new Razor-aware logic. Expected output is in expected-output.txt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
S5256 (tables should have headers) raises false positives on Razor layout pages, where the
<table>sits in the layout and the<th>rows are injected by@RenderBody,@RenderSection, or@Html.Partial/@Html.RenderPartialfrom a child view. This PR adds a symmetric exemption to the existing Thymeleaf fragment-insertion logic.Changes
TableWithoutHeaderCheck.startDocumentpre-scans.cshtml/.vbhtmlfiles forTextNodes containing Razor fragment-rendering expressions (@RenderBody,@RenderSection,@RenderPage,@Html.(Render)?Partial(Async)?, with or withoutawait); every<table>ancestor of such a node is exempted from S5256.Helpers:isRazorFile(HtmlSourceCode)andcontainsRazorFragmentRendering(String)..cshtml/.vbhtml/.htmlfixtures covering the FP cases and the non-suppression invariants (real bug in a Razor file, Razor-looking text in a plain.htmlfile).Functional Validation
Attached: SONARHTML-170-fv.zip
Unzip and run:
Expected output is in
expected-output.txt. The README shows the before/after comparison so you can reproduce the difference directly.