Open rucciva opened 6 years ago
I can reproduce using your commit bebaeb7
.
It's due to a limitation of SonarGo analyzer that only provide covered/uncovered lines to SonarQube API. And if we focus only at line numbers, the result is right ( (1−5983÷15583)×100 = 61.6 )
Go coverage report contains range of source code (from line,col to line,col). So a line can be partially covered. SonarQube API support partially covered lines with a list of covered/uncovered conditions, but the conversion from go report ranges to sonarqube conditions was not a straight forwards conversion and has been simplified to only support line numbers.
As a prerequisite to fix this difference, SonarQube API should evolve to support covered text ranges
and not covered text lines
Go Tool Coverage: 59.0% SonarQube Coverage: 61.6%
SonarQube Scanner: 3.2.0.1227 SonarQube Server: 7.3.0 Golang Version: 1.11.0
Generate Coverage Commands (i am using an open source project as an example):
The coverage file:
coverage.out.zip
Go Tool Cover Output:
SonarQube Scanner Commands:
Sonarqube screenshot: