New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional disablement for pattern matching else branch #1033
Comments
Ran into the same issue and decided to see if there's a pull request or anything Running macOS 14.2.1 My system shows ≈90%+ line coverage, but just ≈75% branch coverage. I was fairly surprised because I do test all significant branches, and those untested were mostly from generated boilerplate and weren't that important to test. The thing is: we shouldn't care for an So I'd like to have an option to handle that, too |
Overview
Hello. 👋 I'm not sure if this is a bug or a feature request but opting to go with the latter. I'm hitting a situation, with pattern matching, where I don't think I necessarily want code coverage for the
else
branch when I've configured SimpleCov as follows:Consider the following code:
I'm using pattern matching and monads for a functional design. Situations in which I'd hit the
else
branch is low because a monad can only be aSuccess
orFailure
. It's not impossible, only very rare to hit theelse
branch. As an added benefit of pattern matching -- should theelse
branch be hit -- I'll get aNoMatchingPatternError
exception so I'll know immediately if this situation occurs. That last statement makes pattern matching unique versus a traditionalcase...when
statement and why I'm bringing this issue up.One workaround -- and the most obvious -- is to always implement the
else
branch:The other workaround is to ignore code coverage for the
else
branch entirely:The only problem with either of these workarounds is that all of this gets tedious quickly for minimum benefit. 😢
Screenshots/Screencasts
Here's a screenshot of the report as generated by SimpleCov:
Steps to Recreate
To recreate, run the following:
unzip demo.zip
.demo
.bundle install
bundle exec rspec
open coverage/index.html
Environment
The text was updated successfully, but these errors were encountered: