alfert/coverex

Module.__info__ not covered

zaboco opened this issue · 4 comments

When I run the coverage report for a module, I get uncovered lines in the special __info__ function. Is this function supposed to be tracked?

I'm using Elixir 1.2.2 and :coverex, "~> 1.4.7"

The __info__ is automatically generated by the Elixir compiler and thus has no source code. The coverage information comes from the standard Erlang coverage utility. And Erlang does certainly not know that __info__ is generated, as it appears to the Erlang VM only a function with a funny name.

From that perspective it looks like a good idea to filter that function out of the report.

@alfert are you saying a PR should be made to filter out __info__? I wonder if it would be possible to mark functions to be ignored using module attributes the way credo added @lint for per-function configuration.

Yes, good idea. Basically, I mean the Erlang coverage tooling is not configurable in that sense, but we have the reporting of the coverage results in our hands. Thus, it should be possible (I assume even easy) to filter out uninteresting functions.

I have no experience yet of using module attributes for such purposes, but there should be plenty examples to figure out how to create the connection from the appearance of the attribute and the following function definition (e.g. credo or ex_doc).

Module attributes make no sense for functions __info__ and __struct__, so I simply filter them out. I am hesitant to add an @ignore_coverage since it breaks the entire approach of measuring coverage information. In particular the trend is important and not the absolute value - so it does no harm to see that the coverage is at 60%. It requires a conscious decision whether 60% is an adequate test coverage.