This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Description
I have a couple of if statements which if matched return. One of the two will return in all real-world cases so I want to ignore the fallback return statement.
I'm reading the docs at https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md and it looks like the following should do what I want:
if (diff > 0) return 1;
/* istanbul ignore else */
if (diff < 0) return -1;
return 0;
But I'm getting told that the return 0 line is not covered. If I instead use a /* instanbul ignore next */ just before the return 0 line, now it tells me that the if (diff < 0) line is uncovered.
I found that I need to include both ignore statements:
if (diff > 0) return 1;
/* istanbul ignore else */
if (diff < 0) return -1;
/* istanbul ignore next */
return 0;
Is this as intended?
I found I can also do this, but I don't like the code:
if (diff > 0) return 1;
/* istanbul ignore else */
if (diff < 0) return -1;
else return 0;