SonarQube New Code section showing shifted line numbers for HTML fileIs there any

Hello Team,

I am noticing an issue with SonarQube’s New Code detection when scanning an updated HTML file.

I added the following new block in my HTML file:

<section class="card">
    <h2>Horses__c</h2>
    <p>Full CRUD permissions.</p>
</section>

Horses__c

Full CRUD permissions.

This block was added between lines 71–74 in my editor.

However, after triggering a scan in SonarQube, the New Code highlight appears between lines 72–75 instead.

You can refer to the attached screenshots:

Screenshot 1: Editor showing the actual new code added at lines 71–74

Screenshot 2: SonarQube UI showing the New Code block highlighted at lines 72–75

This indicates a 1-line shift between the actual new code and SonarQube’s calculated new code.

Questions / Request for Clarification

Is this behavior expected in SonarQube?

Does SonarQube internally normalize line endings, whitespace, or HTML formatting that could cause a line shift?

Is there any configuration or setting we can adjust (e.g., SCM) to ensure SonarQube matches the exact line numbers from the source file?

If this is not expected, could you please confirm if this is a known issue or provide guidance on how to correct this behavior?

Environment Details

SonarQube Edition: Community

SonarQube Version: v25.5.0.107428

Scanner: SonarScanner

File type: .html

Lines involved: Editor (71–74) vs SonarQube (72–75)

Please let me know if you need the file itself or the full diff to investigate further.
Looking forward to your clarification.

Thank you!

Hi,

Your investigations show the new block pushed down by one line. Can you further investigate and identify the extra line that’s pushing it down?

 
Thx,
Ann

Hi,

After carefully Investigating the pattern. We understood that the issue is with the html/xml blocks. Since, line 71 and line 75 are same line of code. We are assuming New Code Block feature is considering line 75 as new line of code instead of line 71.

Hi,

What’s new is identified based on SCM data. The two lines being identical shouldn’t have any bearing here.

Did you identify what the extra line is that’s pushing down the new block?

 
Ann

Hi,
No extra line is pushing down the new block. I just have added 4 line block as you can see in my github (scm) patch data :

Hi @dhanushterala1509,

I guess you work with the OP?

Then… there’s no problem?

 
Ann

Hi Ann,

I work with the OP. We’re seeing an issue where GitHub shows our added lines as 71–74, but SonarQube marks the New Code block as 72–75. We didn’t understand what you meant by an “extra line pushing down the new block.” Could you clarify what line you’re referring to or how we should identify it? The actual issue we’re observing is that SonarQube highlights line 75—which is unchanged—as New Code instead of the actual added line 71.

For better clarity and to help with analysis, we can share sample (non-PII) HTML files. so the behavior can be replicated if needed.

Hi,

Okay! So then in SonarQube the new block is “pushed down” by one line. Can you please investigate above line 71/72 and see what extra line SonarQube has that GitHub does not?

 
Thx,
Ann

Hi,
The file in SonarQube and the file in GitHub both show 84 total lines and the same lines of code. There’s no extra line in SonarQube that isn’t in GitHub, and nothing is being pushed down by additional content. I only added four lines of code in GitHub (lines 71 to 74). However, SonarQube is incorrectly displaying the new block as lines 72 to 75.

For clarity:

Line 70 is an empty line.

Line 71: <section class="card">

Line 72: <h2>Horses__c</h2>

Line 75: <section class="card">




Hi,

Okay, I finally understand. It’s not that the content is pushed down a line. It’s that the ‘new’ marking is pushed down a line.

Can you share your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

Hi,
I attached sonarqube analysis logs.

Analysis_redacted.log (48.5 KB)

Hi,

Thanks for the log. Here we go:

13:31:56.817 WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.

Analysis uses SCM metadata to understand what’s new. If that’s not available, it estimates. This is the result.

These prerequisites are listed for PR analysis, but are also generally applicable.

 
HTH,
Ann