Versions used: Version 18.104.22.168217 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.
Image is showing the coverage on new code (dispite I covered ALL my new code) that I got running a Pull Request Analysis, on base line coverage is 0%
Welcome to the community!
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.
Hello G Ann,
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.
Your SCM is telling SonarQube that the lines are new. When you click on it in the margin, what date do you see? E.G.
I marked in yellow the analysis and code date.
Thanks for the screenshot!
Now could you also check your front page and send a screenshot of when your New Code period started? In 8.2 it looks like this:
In 7.8 (you really should upgrade, you know) you’ll find it at the top of the yellow column on the project homepage.
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?
Sorry, I missed your last reply.
You can pass
-Dsonar.verbose=true to the scanner.