uartois / sonar-golang

Sonarqube plugin for the golang language.
GNU Lesser General Public License v3.0
245 stars 32 forks source link

ERROR: Error parsing coverage info for file coverage.xml: Invalid go coverage, expect 'mode:' on the first line. #77

Open hieu29791 opened 5 years ago

hieu29791 commented 5 years ago

Description

ERROR: Error parsing coverage info for file coverage.xml: Invalid go coverage, expect 'mode:' on the first line

Steps to Reproduce

1. go get github.com/axw/gocov/gocov;
2. go get github.com/AlekSi/gocov-xml;
3. go test -coverpkg="./controllers" -coverprofile=cover.out;
4. gocov convert cover.out | gocov-xml > coverage.xml;

Content of your sonar-project.properties

sonar.sources=./
sonar.exclusions=cathay_cc_test.go,libraries/**/* 
export SONAR_SCANNER_OPTS="-Xmx1024m"
sonar.sourceEncoding=UTF-8
sonar.go.coverage.reportPaths=coverage.xml

It will help us to check how you configured the plugin.

Log of sonar-scanner related to the plugin

sonarqube

juliorenner commented 4 years ago

Could you solve it? I am facing the same issue

juliorenner commented 4 years ago

I got rid of the error by sending the cover.out file.

jcollum commented 4 years ago

@juliorenner the docs say you have to use xml format:

For coverage metrics you must have one or multiple coverage.xml (cobertura xml format) files.

The .out file generated by go tool cover is not xml. For instance:

go tool cover -func cover.out -o /go/src/foo/bar/coverage/api.cov generates:

foo/bar/api/dao/dao.go:46:                  AccountExist            85.7%
[etc]