SonarCloud - False positive Web:S5254 with Thymeleaf

SonarCloud does not seem to recognize HTML lang declarations when using Thymeleaf - a HTML template engine, which means my lang tag is called “th:lang” instead of “lang”

Any chance this could be added to Sonar?

The following example HTML will trigger Web:S5254

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" th:xmllang="${#locale.language}" >
    <head>
        <title>Example</title>
    </head>
    <body>
    </body>
</html>

Hey there.

I’ve moved your post to the section on reporting false-positives. Please be sure to read this post:

And include the version of SonarQube you’re using, and a reproducible code snippet (not a screenshot).

1 Like

Hi Colin
Thank you for moving it, I added the information my post was lacking, sorry about that.
We are using SonarCloud, I am therefore unsure if it has a specific version.
Cheers

Hey @ozzi,

Indeed, this is a false positive and should be considered in the analyzer. I’ve created a ticket to track this: [SONARHTML-160] S5254 should not raise an issue when the lang is specified with Thymeleaf attributes - SonarSource. I cannot tell yet when the fix will be released.

Thank you very much for reporting this!

1 Like

Hi Karim
Great, thanks for creating the ticket.
Cheers