scoverage / scalac-scoverage-plugin

Scoverage Scala Code Coverage Core Libs
https://github.com/scoverage
Apache License 2.0
423 stars 126 forks source link

Case statements should be counted as branches #493

Closed jrglee closed 1 year ago

jrglee commented 1 year ago

The readme mentions that branch coverage includes if/else, pattern matching, partial functions and try/catch/finally. But currently, it only supports if/else and try/catch/finally. All the case statements are not covered as branches. This means pattern matching, partial functions, catch blocks and any ad-hoc match statement that functionally acts as an if/else block.

This change follows what was done in the early versions of the repo and instruments the case statements as branches. Since case statements are also used as sentinels, it is necessary to parameterize the transformCases helper to distinguish when to actually instrument with branching or not.

This addresses #96 which has been open for quite a while already.