sonar-golang icon indicating copy to clipboard operation
sonar-golang copied to clipboard

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

Open hieu29791 opened this issue 6 years ago • 3 comments

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

hieu29791 avatar Aug 02 '19 05:08 hieu29791

Could you solve it? I am facing the same issue

juliorenner avatar Feb 21 '20 17:02 juliorenner

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

juliorenner avatar Feb 21 '20 17:02 juliorenner

@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]

jcollum avatar Mar 26 '20 18:03 jcollum