Codecov missing coverage of myfunction(::SomeType) = 1

I have some packages that previously had 100% code coverage but now the badges are showing <100% coverage because codecov is falsely claiming that some lines that look like
myfunction(::SomeType) = 1
are not being covered, when in fact I am sure they are covered.
I have a hunch that the compiler is optimizing these functions away and codecov does not realize that. Is there any way to make the codecov report more accurate?

Here is a concrete example report (but I don’t know if such reports are publicly viewable):

1 Like

Known issue, see, for example:

2 Likes

Thanks! I had searched discourse for info and couldn’t find anything, figuring it was a codecov bug. I didn’t realize it was an issue with Julia itself.
And indeed my examples are always cases where the function returns an isbits literal.
What is not mentioned in that Julia issue is that these things used to be covered properly not that long ago, so some change in 1.10 or 1.11 or so caused the problem.

1 Like

I think this is a long-standing issue for Julia. It’s probably just that the bug didn’t trigger for your code before, perhaps because Julia wasn’t able to constant-fold the relevant pieces of code previously.

So apparently you can now ignore such problematic code with this directive:

To exclude specific code blocks, surround the section with COV_EXCL_START and COV_EXCL_STOP comments:

# COV_EXCL_START
foo() = nothing
# COV_EXCL_STOP

To exclude a single line, add a comment with COV_EXCL_LINE:

const a = 1 # COV_EXCL_LINE
3 Likes

Thanks - that’s a helpful workaround until the Julia issue gets fixed.