Sonar coverage is 0% on Go files with enums only

We do understand that at the root this is GoLang problem.

We have GoLang files that have only constants and enums and the go test command will ignore these from reports since it considers there is no logic in them. As a result Sonar will report that there is 0% coverage which breaks our Quality Gates.

We can work around the issue by adopting a naming convention and ignore files matching **/*_enums.go from coverage but as soon as someone adds a method in these files, then the coverage will still be unreported, even though go test will report coverage.

Many of our go dev are blaming Sonar, which is just the messenger, but the messenger could be a bit smarter about what to report based on the language. I suppose excluding import, const and enum lines as an option could take care of the mis reporting issue.

Hello, thanks for the feedback.

I agree that the current situation should be improved and that the workaround you are using is far from ideal. I don’t see any better one though.

There is already a ticket (SONARSLANG-451) to fix our coverage to match “go test”, I added a comment there, and a link to this post.

I hope it clarifies the situation,
Quentin

Thanks for following up.