Add `codecov` format support to the `unreachable` command
Blacksmoke16 opened this issue · 2 comments
Feature Request
As discussed in https://forum.crystal-lang.org/t/usability-of-code-coverage/7249, crystal does not include unused methods within the resulting binary. Because of this, the reports generated via kcov are unable to mark them as uncovered. However, this is precisely what crystal tool unreachable
is meant to do: find and report unused methods.
I propose that a new codecov
format be added to the tool. This would allow doing something like crystal tool unreachable --format=codecov src/app.cr > cov.json
, which could then be uploaded to enhance the original kcov report with uncovered lines.
Dev Notes
- I don't think we really have a way to determine partial hits, so we'll likely need to just rely on the integer value path, versus the
"1/3"
string values.
What would a partial hit in this context even mean? A method either gets instantiated or it does not.
My understanding, based on https://docs.codecov.com/docs/viewing-source-code#partially-covered-lines, is it's for lines that have branching logic. For example:
value = cond ? true : false
If cond
was only ever truthy, then this line would be partial 1/2
hit since there was a branch that was not hit. unreachable
only handles method level coverage so is inapplicable.
I am still unsure if the report should mark every line of the method as missed, or only the line defining the method. I'm leaning towards the former as it's more accurate given the line level granularity of these coverage tools.