Hello Team,
We are observing an issue with SonarCloud New Code detection for an updated HTML file, where the lines highlighted as New Code do not align with the actual changes made in the source file.
CI system used
Local execution using sonar-scanner
Scanner command used
sonar-scanner
analysis_redacted_1.txt (1.4 KB)
Languages of the repository
HTML
SonarCloud project URL
Not public
github diff for p.r branch :
Pull Request URL
Error observed
We added the following content to an existing HTML file:
<section class="card">
<h2>Ho__c</h2>
<p>Full CRUD permissions.</p>
</section>
This block was added between lines 77–80 in the source file (as shown in the editor and GitHub diff).
After running a SonarCloud analysis, the New Code section in the SonarCloud UI highlights lines 78–81 instead.
As a result:
One newly added line (line 77) is not marked as New Code
One unchanged line (line 81) is incorrectly marked as New Code
This suggests a one-line offset between the SCM diff and SonarCloud’s New Code calculation.
Steps to reproduce :
Added html to github repo.
Ensure SCM is enabled and accessible from the terminal.
Run sonar-scanner analysis on the main branch to sonarcloud.
Create a pull request branch in github with above change.
sync with github in local repo ( terminal ).
Run sonar-scanner on the pull request branch.
Compare the GitHub diff with the New Code highlighted in SonarCloud.
Potential workaround
No workaround identified so far.
The issue currently blocks accurate New Code identification.
Questions / request for clarification
Is this New Code line shift expected behavior in SonarCloud?
Does SonarCloud normalize line endings, whitespace, or HTML content in a way that could affect line numbering?
If this behavior is not expected, is it a known issue or are there recommended steps to resolve it?
Environment details
Sonar Edition: SonarCloud
Scanner: SonarScanner
File type: .html
Lines involved:
Source editor / GitHub diff: 77–80
SonarCloud New Code: 78–81

