On importing coverage.out file into sonarqube, still getting 0% in overall coverage

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube => 9.1
    Scanner => SonarScanner 4.6.2.2472
  • what are you trying to achieve
    Trying to import coverage.out file in sonarqube still getting 0% in overall coverage
  • what have you tried so far to achieve this
    pipeline script
${scannerHome}/bin/sonar-scanner \
                    -Dsonar.projectKey=freshdesk_collab \
                    -Dsonar.sources=. \
                    -Dsonar.host.url=https://quality.***.com \
                    -Dsonar.login=*** \
                    -Dsonar.sourceEncoding=UTF-8 \
                    -Dsonar.exclusions=**/vendor/**,**/src/**/*.html,**/client/** \
                    -Dsonar.go.coverage.reportPaths=$WORKSPACE/server/src/coverage.out
                    '''

log

INFO: Sensor Go Cover sensor for Go coverage [go]
INFO: Load coverage report from '/home/jenkins/workspace/SonarQube-freshconnect-collab-golang/server/src/coverage.out'
WARN: File '/server/src/model/message.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/payload.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/message_metadata.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/conversation.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/user_preference.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/message_receipt.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/account_channel.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/product.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/conversation_channel.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/product_context.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/thread_member.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/product_account.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/yp_fw_account_user.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/product_user.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/yp_account.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/yp_user.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/user.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/yp_user_realm.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/yp_fw_account.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/account.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/mapping.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/thread.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/conversation_member.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/user_channel.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/yp_account_realm.go' is not included in the project, ignoring coverage
WARN: File '/server/src/model/yp_realm.go' is not included in the project, ignoring coverage
INFO: Sensor Go Cover sensor for Go coverage [go] (done) | time=48ms

Screenshot 2021-10-29 at 12.04.23 PM

I’ve also run the native go tool to verify the coverage.out

go tool cover -func="coverage.out"

coresponding logs

...
model/yp_user_realm.go:410:		GetYpUserRealmsByYpAccIDAndYpAccRealmIDAndYpUserIDs				60.0%
model/yp_user_realm.go:433:		GetYpUserRealmsByYpAccIDAndFwUid						60.0%
model/yp_user_realm.go:456:		DeleteYpUserRealmByYpAccIDAndYpAccRealmIDAndYpUserID				57.7%
model/yp_user_realm.go:514:		UpdateYpUserRealm								51.6%
model/yp_user_realm.go:587:		DeleteYpUserRealmsByYpAccID							66.7%
model/yp_user_realm.go:606:		InsertIntoSearchService								55.6%
total:					(statements)									53.5%

Hi,

Thanks for including the analysis log!

This seems to be a case of path mismatch. Analysis needs to see in your coverage reports the same paths it’s seeing in analysis. It seems that your coverage report contains absolute paths from root (leading /) rather than paths relative to the analysis workspace.

 
Ann

Hi Ann,
thanks for the response, however, we have some coverage in the coverage.out file. Due to path mismatch, a few files have been ignored but we should get the remaining percentage (files) in sonarqube , but no luck (we are getting only zero as overall coverage) Can you please help with your inputs here?

thanks
Vignesh MM

Hello @Vignesh_Murugesan

Did you manage to solve your problem? If yes, it would be great if you could share with us what was the problem.

If not, I invite you to have a look at this example of how someone configured his project.

And eventually at this related post:

Hope it will lead you in your researches.
If you are still stuck, feel free to come back to us with updated information.

Best,
Quentin