Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/cover: inconsistent treatment of comments #22545
Run coverage on the following program using these commands:
This is the rendered HTML output:
Observe that the first comment is grey, not green, even though it was covered. Is this a simple bookkeeping error, or is there a design reason why we shouldn't consider the entire span from
(This is Google internal issue 68650370.)
@dsymonds adding more comments to the uncovered section in your example does not decrease test coverage, the numbers are the same even if there are more non-green lines.
The colours are however misleading as you say, some are green and others are not. I've been looking into this, not in the "cover" tool but in a variant(based on the original) which outputs the result to a terminal.
However I disagree that the function signature should be grey, it is called during execution isn't it?
In my variation I actually changed this to only use green and red colours which resulted in
Changes can be summarized as
Benefit of this is the reader only has to scan for the red colour, grey and green basically mean the same within a function context.