Test coverage for an expression with logical conjunction

Consider the following expression which is commonly used for conditional rendering in React:

{props.corridors.length > 0 && <br />}

When fully tested its coverage ratio will never exceed 50% as there’s no way to arrive at the scenario where the second operand (<br />) happens to be false. Do we have any workarounds to tell sonar that this expression can only really end up in one of two states and it shouldn’t be considering all four possibilities?

Hey there.

SonarQube reads this information from the coverage reports it is fed (including missing conditions). It doesn’t take decisions about this on its own. You’ll want to raise an issue with the coverage reporter you’re using if you believe there’s an error.