Golang coverage imprecise

Hi there,

I think I’m encountering a bug. I tried working around this for a while now but it seems its not possible.

I am using a go monorepo with multiple microservices (and several languages). I setup exclude and test patterns:

exclude_patterns = [
    "**/*.js",
    "**/*.sql.go",
    "**/*.gen.*",
    "**/node_modules/**",
    "build/**",
    "dist/**",
    "e2e/**",
    "gen/**",
    "node_modules/**",
    "shared/go/testutils/*.go",
]

test_patterns = [
    "**/*_test.go",
    "**/__mocks__/**",
    "**/main.go",
    "**/mocks.*",
    "**/mocks/**",
    "**/tests/**",
    "**/vitest.*",
    "vitest.*",
]

This works to exclude all the generated code and test utilities. Note - i excluded them completely, but I also tried using the test_patterns for them with similar results.

Whats happening? This allowed me to narrow down the coverage issues reported only to the files i wanted covered, and fix all the coverage issues. I now have exactly zero coverage issues related to go, and running the go CLI test command shows I have 100% coverage for all the files that I want covered.

BUT - the reports in deepsource are stuck around 80% coverage. It seems that deepsource still factors in the excluded code when calculating the coverage. This makes the use of the quality gates impossible really.

Hey @Goldziher — can you let me know the org and repo name? We’ll check what’s happening here.

certainly

basemind-ai/monorepo

Please check why the Kotlin condition and composite coverage is at 80 percent. There is no explanation fo this whatsoever.

Also - the documentation coverage seems to be broken-

  1. there is not kotlin in the documentation coverage.
  2. documentation coverage seems to factor in tests?!
  3. documentation coverage does not seem to update correctly.