Wrong number of lines showing in Coverage section on PRs

I created a project on sonar cloud and a dev branch exists in it and it is showing in Long-Lived Branch and sonar cloud has analyzed it for the first time and when PR is created with the few lines changed sonar cloud is showing a lot of new lines to cover and coverage is showing less than 80% while the change happened only in few lines. Due to this reason Quality Gate is showing Failed status.

I deleted the project and created it again but same thing is happening again.

Please help me to overcome this issue.

Thanks

Hi,

Welcome to the community!

How about some screenshots of these new lines to cover that you think are wrongly detected as such. And also a screenshot of the blame data for a block of those lines. You can get that by clicking in the left margin:
Selection_886

 
Ann

when i am clicking on Lines to cover it is showing me Uncovered lines not showing Lines to cover, i have attached the screenshot for that

Hi,

The topic seems to be changing here…

Nonetheless, ultimately ‘lines to cover’ will either be covered or uncovered (or partially covered in the case of conditionals). So yes, you’re seeing red markers to indicate which Lines to Cover are currently uncovered, or still in a “to cover” state.

 
HTH,
Ann

I have created a new testing branch from dev (main branch) and no new lines added but it is still showing 21K new lines to cover in the coverage section while the dev (main branch) is already analyzed, I am attaching the snapshot from testing branch

This is the snapshot from dev main branch

Can we schedule a meeting to discuss this issue if possible?

Thanks

Hi,

Sorry, no meetings. Care to share the analysis log from the latest branch?

 
Ann

Ok no problem, so how I can access the analysis logs?
May you please guide me.

Thanks

Hi,

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.

 
HTH,
Ann

Many thanks for guidance, so what kind of information you need from the logs? Logs information is too long so how I can send you the appropriate information from logs?

Thanks

Hi,

I’d like to see the full analysis log. How long is it?

 
Ann

It contains thousands of lines.

Thanks

Hi,

Could you turn off debug/sonar.verbose?

 
Ann

Yes sure, i turned off this debug/sonar.verbose.

Thanks

Please share email address so I can share the logs on email because these are the company project logs so I cannot share these logs on this public forum.

Thanks

Hi,

Feel free to redact the logs as necessary.

 
Ann

I am attaching sonar cloud code analysis logs here,





Hi,

Please provide this log in text format.

 
Ann

here i am attaching logs in the text file.
sonarcloudlogs.txt (71.3 KB)

Hi,

Here’s the problem:

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.

Without SCM data, analysis is going to have a hard time correctly identifying what files / lines are new.

So the question is: how do you obtain the files for analysis? Analysis assumes that it’s kicked off from the project root directory, which is also the SCM root directory. Without the SCM’s dot files (files or directories with names that start with .) present starting from the analysis root directory, you’re going to get results like you’ve experienced.

 
Ann

Hi,
we have disable the SCM Sensor in the Sonar Cloud but we still facing the issue and i am attaching the snapshot of Jenkins file in which we analyzing the code for PR,

Thanks