Sonarqube Scanner detects the existing code as the new code

Created the Sonarqube setup with the below details and the deployed sonarqube scanner version is 4.6

  • Community Edition
  • Version 10.0 (build 68432)

In Sonarqube server we have created the project for our each microservice with our main branch (overall code).

As part of every gitlab merge request creation we have enabled the pipeline to capture the current branch code coverage and another pipeline is to capture this coverage output file and scan the same using sonarqube scanner and finally push the scanned result to the sonarqube server.

In Sonarqube server we have enabled the Quality Gate condition to validate the code coverage and duplicate lines for the new code.

In the Project settings → New Code → Selected "Define specific version for this project → specific analysis → selected the 1st version (overall code) i.e the version which got created at first time.

My intention is to compare the new code every time with the overall code(main branch) so that i can make sure the new codes are meeting my Quality Gate conditions.

The issue i am seeing is, in the project the new code , couple of lines are complaining about the code is not being covered but is not part of the current gitlab branch , where this piece of code is already existing in the main branch.

can someone please assist me on solving this issue ?


Welcome to the community!

Could you share a screenshot (redacted as necessary) of these uncovered, old lines shown in the MR analysis?

Can you also share the 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.