Code coverage measures the proportion of specified code, paths, branches, or behaviors exercised by automated tests. It acts as an early signal of code quality rather than a complete measure of software reliability. section 10.1.2 section 10.8
Coverage can guide improvement before production problems occur, especially when combined with code-quality violations and the ratio of manual to automated tests. It should therefore inform engineering decisions alongside delivery and reliability measures. section 10.1.2
Blocking deployments below 80% coverage
An engineering organization requires custom code to reach 80% coverage. A Kubernetes admission controller sends deployment metadata, including a commit SHA, to an OPA policy. The policy retrieves matching coverage results from Codacy, compares the reported value with 80, and denies deployment when the value is lower. A result for commit bc183a62 reports 98% coverage, so it satisfies the threshold. section 4.2.1
package test
# http.send request passing our input data could go here
default deny := false
deny if code_coverage_lt_required
code_coverage_lt_required if {
data.code_quality_attributes[input.request.object.metadata.sha].coverage < 80
}
Inspect the Rego rule that retrieves code-quality data and denies deployment when coverage falls below the required threshold. section 4.2.1
A practical coverage gate requires:
- A reporting system that records coverage against an identifiable commit or deployment revision. section 4.2.1
- A policy that defines the required threshold and specifies the response when coverage data is below it. section 4.2.1
- Complementary metrics that connect coverage to developer productivity, operational efficiency, and customer outcomes. section 10.1.2













