SonarGo with Go Module code coverage issue

  • Sonar Developer Edition 7.9
  • SonarGo 1.6
  • Coverage report

Similar this post https://github.com/SonarSource/sonar-go/issues/218

We are maven build using mvngolang-maven-plugin, and able to get mvngolang to create target/coverage.out at each maven module

We have correct settings of

<sonar.go.coverage.reportPaths>${project.build.directory}/coverage.out</sonar.go.coverage.reportPaths>

maven sonar:sonar shows the following warings

 [WARNING] File 'xxxx/yyyyy.go' is not included in the project, ignoring coverage

xxxx is Go Module name yyyy.go is under ${project.basedir}/src

It would like to know if any one able to get Go with Go Module code coverage working yet?

Thanks

-D

@sonargo team, do you a sample of Go module with code coverge showin up at sonarq?

-D

Hi,

xxxx/yyyyy.go displayed in the log is just read from your coverage report. According to

xxxx/yyyyy.go is not a correct path. Coverage report should either contain absolute paths or paths relative to a project base directory.

Here is the code which does file resolution, may be it will help you to clarify what’s going on -> https://github.com/SonarSource/slang/blob/674b299a11a8c18a031f287655686b3e82b114b2/sonar-go-plugin/src/main/java/org/sonar/go/coverage/GoCoverSensor.java#L109-L130

Great news, I am able to use antrun to alter the paths to use full path under coverage.out before running sonar:sonar goal. It works

However, It would be great if Sonar Go can be more Go Module aware? so we dont the implemnt this work around?

hello @dantran,

we plan to do that, here is the ticket https://jira.sonarsource.com/browse/SONARSLANG-450
However, I can not provide any ETA for it.

Thanks @saberduck looking forward for the fix but I am all good with work around