Versions used: Version 7.8.0.26217 Developer Edition
Error observed: Coverage on new code is considering the whole file, not new code only. I have a java file that its coverage is %0 on the base line,I am doing unit test to all my new changes (with a 100% coverage on all new code), however sonar is getting the coverage of all code, breaking the my quality gate. I am running a Pull Request Analisys.
I’m glad you included a screenshot because the yellow highlight is showing me that SonarQube appears to be considering all the lines in your file as new/changed. We’ve seen this happen when you (or perhaps your automation) change/standardize, for instance spacing or line endings in the file. Could that have happened?
And BTW, this is “new” as reported by your SCM. We rely on the data it supplies.
The code isn,'t new since the first analysis, I mean, I ran an analyse using the main branch to set the base line, afterward, I ran the Pull Request Analysis.
In the image I´m attaching you can see my pull request from Azure DevOps (the same code I shown in the last post), the red square mark the change, and the blue one confirm that there is no changes in the next lines.
Next thing to check is if the scanner is able to read the information from git. More specifically, what are the changed between the P/R and it’s target branch.
When scanning the P/R, could you please provide the logs of the scanner with debug enabled?