We have a common main branch being used as target. Since, multiple teams are using the same branch to commit to, and the new loc aggregate rule is set to >=80%.
Sometime, a PR gets merged with individual file having coverage less than 80 (due to being averaged out to be more than 80, because of 100% coverage in other files), but when new PR comes in it fails due to older commit from main showing aggregate coverage less than 80.
( For eg, PR1 gets merged with 2 files with coverage 75% , 100% respectively, PR2 has good enough coverage but 1st file from main now fails with less coverage)
Is there any way to set a rule to check coverage >=80% per file ?
First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:
Regarding your actual question, what you’re encountering is what I call the “fudge factor”. Coverage requirements aren’t enforced when there are fewer than 20 changed lines. Once you upgrade to 9.1, you’ll find a setting to turn that behavior off & always enforce coverage requirements.