Closed kernle32dll closed 6 years ago
Thanks for pointing that out.
It is indeed the case that we do not filter out files ending with "_test.go" for those metrics (see https://github.com/uartois/sonar-golang/blob/cb6767754e29338baaf816085b587dc5ab22c030/src/main/java/fr/univartois/sonargo/core/metrics/GoMetricSensor.java#L33)
We will fix that asap.
Fix confirmed - thanks for the quick response! :-)
Description
I realized today that the content of go test files is counted against the total project lines-of-code. I checked against SonarJava, as I was not sure if this might be desired behavior - but its not.
The inherit problem is that test files are parsed as regular source code. This also has the side effect that gometalinter issues for test files are also shown in SonarQube.
Steps to Reproduce
foo.go
)foo_test.go
)Content of your sonar-project.properties
Log of sonar-scanner related to the plugin
Nothing useful, as no errors happen.
Versions
SonarQube: 6.7.1 (build 35068) SonarScanner: 3.0.3.778 sonar-golang: sonar-golang-plugin-1.2.11-rc-reubentfix (also verified on rc7 and rc8)
Additional Information
I tried to add
./*_test.go
to thesonar.exclusions
andsonar.tests
insonar-project.properties
. I thought, that maybe sonar-go just doesn't correctly pick up the test files (not sure if it can code-wise anyway?). However, that just resulted in a nasty stacktrace. This is a different issue, but this definitely prevents setting a correct expression for distinguishing between code and tests....