open-policy-agent / opa

Open Policy Agent (OPA) is an open source, general-purpose policy engine.
https://www.openpolicyagent.org
Apache License 2.0
9.52k stars 1.32k forks source link

Different coverage reported using one-liner `if` rule compared to one-liner in body #6531

Open anderseknert opened 7 months ago

anderseknert commented 7 months ago
package test

import rego.v1

foo if {
    false
}

test_foo if {
    not foo
}

As far as I can tell, this test excercises all possible code paths (as there is only one, really). The test coverage reported is however only 75%, as line 5 (foo if {) is considered not covered. This despite the line in the body reported as being covered. Changing this to use one-liner style:

foo if false

Has coverage reported as 100%, despite being the same thing covered (!) in some syntax sugar.

stale[bot] commented 6 months ago

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.