Skip to content

Identifying which lines are covered by a statement #1308

@Bachmann1234

Description

@Bachmann1234

Howdy! Its been a while! I hope things are going well.

Is your feature request related to a problem? Please describe.
As you may recall I maintain diff_cover. Recently an issue was opened up that honestly kinda shocked me as it seems like something that should have come up years ago.
Bachmann1234/diff_cover#270

Diff cover attempts to compare a diff to a coverage report to identify what changes have been covered by tests. However, coverage reports identify statements. While diffs cover lines. So in an example like this coverage is like "Well this statement is not covered". While diff cover happily looks at this diff. Sees the line is not in the report at all and assumes its fine (things like comments would not show up in a coverage report and we would not want to flag those as 'not covered')

(this example is showing the html report as it is clearer for humans. In practice we use the xml report)
Screen Shot 2022-01-22 at 3 52 43 PM

Screen Shot 2022-01-22 at 3 53 03 PM

Describe the solution you'd like

Well, ill be honest I am open to ideas here. I was thinking of two potential ones.

  1. Is there something that could be added to the xml report the indicate the range of lines covered by each statement
  2. Maybe a setting to measure line coverage instead of statement coverage?

I am somewhat concerned that neither of these are technically feasible... as I wonder if you run into the same issue I run into where the data you collect can only see statements and the 'knowledge' of statements broken up into multiple lines is lost in the analysis.

Describe alternatives you've considered

The alternative solution would be for me to do static analysis on the code. Essentially identify the statement a line is a part of. I worry this is a fools errand as I would have to identify which version of python im looking at and successfully parse the text to trace back to the original line.

*I am quite open to ideas on the core issue btw. If you know of alternatives that don't require modifications to coverage im game. *

Thank you for your time simply reading this :-). I am game to be the implementer if there is a feature to be added here. Though I realize that even that may be asking a lot if the feature is a niche as it seems to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions