Skip to content
LatchkeyLatchkey home

JaCoCo "Rule violated for bundle ... lines covered ratio" in CI

The Maven jacoco:check (or Gradle jacocoTestCoverageVerification) goal compared measured coverage against a rule limit and the ratio was below the minimum, so the build fails with the exact measured and required values.

What this error means

The build fails with "Rule violated for bundle X: lines covered ratio is 0.50, but expected minimum is 0.80" and the reactor reports a JaCoCo check failure.

JaCoCo
[WARNING] Rule violated for bundle my-app: lines covered ratio is 0.50, but expected minimum is 0.80
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.12:check (default-check)
on project my-app: Coverage checks have not been met. See log for details.

Diagnose it: did the report reach the service?

Coverage and quality integrations fail in two distinct places: the report was never produced, or it was produced and the upload was rejected. Establish which before touching tokens.

Terminal
# 1. does the report exist and is it non-empty?
ls -la coverage/ && head -5 coverage/lcov.info

# 2. does it reference paths the service can map to the repo?
grep "^SF:" coverage/lcov.info | head -5

# 3. did the upload actually succeed, or just not fail the step?
# most uploaders exit 0 on a rejected upload unless told otherwise

Common causes

Coverage genuinely dropped below the rule limit

New untested code lowered the covered ratio under the configured minimum (line, branch, or instruction), so the rule fails.

The rule scope or counter is stricter than intended

The rule applies at bundle level with a high minimum, or counts a stricter metric (BRANCH) than the team expects, magnifying small gaps.

How to fix it

Add tests to meet the limit, or adjust the rule

  1. Read the measured ratio and the bundle in the message.
  2. Add tests for the uncovered code, or open the HTML report to find the gaps.
  3. If the minimum is too aggressive for now, set it to a realistic value in the plugin config.
pom.xml
<limit>
  <counter>LINE</counter>
  <value>COVEREDRATIO</value>
  <minimum>0.80</minimum>
</limit>

Exclude generated code from the rule

Generated or boilerplate classes can be excluded so they do not drag the bundle ratio down.

pom.xml
<excludes>
  <exclude>**/generated/**</exclude>
  <exclude>**/*Dto.class</exclude>
</excludes>

How to prevent it

  • Run jacoco:check locally before pushing.
  • Raise the minimum gradually as coverage improves.
  • Exclude generated code so the ratio reflects real source.

Frequently asked questions

What causes JaCoCo "Rule violated for bundle ... lines covered ratio" in CI?
There are 2 common causes: coverage genuinely dropped below the rule limit and the rule scope or counter is stricter than intended. New untested code lowered the covered ratio under the configured minimum (line, branch, or instruction), so the rule fails.
How do I fix JaCoCo "Rule violated for bundle ... lines covered ratio" in CI?
There are 2 fixes depending on which cause you have: add tests to meet the limit, or adjust the rule and exclude generated code from the rule. Work through them in order, since the first is the most common.
What does JaCoCo "Rule violated for bundle ... lines covered ratio" in CI actually mean?
The build fails with "Rule violated for bundle X: lines covered ratio is 0.50, but expected minimum is 0.80" and the reactor reports a JaCoCo check failure.
How do I stop JaCoCo "Rule violated for bundle ... lines covered ratio" in CI happening again?
Run jacoco:check locally before pushing. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card