SONARHTML-395 Handle template-generated labels in S6853#715
SONARHTML-395 Handle template-generated labels in S6853#715erwan-leforestier-sonarsource wants to merge 13 commits into
Conversation
de1ce60 to
e260469
Compare
Ruling Report✅ No changes to ruling expected issues in this PR |
asya-vorobeva
left a comment
There was a problem hiding this comment.
It looks like corresponding RSpec description is very confusing: https://musical-adventure-r9qk65j.pages.github.io/rspec/#/rspec/S6853/html
It says that label elements should have a text label (which is obviously wrong for template-generated labels) and doesn't provide list of exceptions. Should we update it?
|
Hi @asya-vorobeva thanks for the review, it's true that the rspec rule description is bad, but it was improved in this PR: https://github.com/SonarSource/rspec/pull/7179 Though there is no exception listed in the rule description because I think that either you fall into one of the exception, in which case you won't see this isuse or you have this issue raised in your code, then I don't think having a list of exceptions will help the developer to fix it. If he thinks that it's a FP because we don't handle the framework it's using, then he can reach out to us and we will investigate the FP. If for example it's just plain HTML, having a list of exceptions for specific frameworks is just noise. Be aware that the rule description has been synced in sonar-html as part of a separate PR and it has been merged into master. See commit a8ae2d3 |
a495abf to
4e89f8e
Compare
Code Review ✅ Approved 2 resolved / 2 findingsUpdates S6853 to correctly ignore template-generated labels in Razor and Thymeleaf, resolving false positives from incorrect fragment detection and unhandled attribute associations. No issues remain. ✅ 2 resolved✅ Edge Case: th:attr recognized for control association but not accessible text
✅ Edge Case: Razor fragment detection runs on non-Razor files in characters()
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
If you check descriptions of other rules, you'll see that we usually provide exceptions in case they exist. I think that documentation about the rule should be full. It's not for users, it's for us developers (ordinary users even don't have an access to full RSpec descriptions). |




Summary
Handle
S6853false positives on template-generated labels by recognizing Razor and Thymeleaf patterns that only resolve at render time.Changes
asp-forlabel is truly empty before trusting its generated textth:forandth:attrassociations, plus template text attributes such asth:text,th:utext,v-text, andv-htmlFunctional Validation
Artifact: SONARHTML-395-fv.zip
Once the file is attached to the PR description, unzip and run:
./run.sh
Expected output: