Skip to content

README badges updated but Codecov not configured - badge links to non-existent coverage #168

@sfloess

Description

@sfloess

Problem

README.md displays a Codecov badge but the project is not integrated with Codecov.io, resulting in a broken/misleading badge.

Evidence

README.md Badge (Line ~5)

[![codecov](https://codecov.io/gh/FlossWare/jcommons/branch/main/graph/badge.svg)](https://codecov.io/gh/FlossWare/jcommons)

Codecov Integration Status

# Check CI workflows for codecov upload
grep -r "codecov" .github/workflows/*.yml
# (no output - NO codecov integration)

What the Badge Shows

Clicking the badge likely shows:

  • "Unknown" coverage
  • "No coverage data"
  • OR redirects to Codecov sign-up

Actual Coverage

JaCoCo Reports (local only):

  • 93% instruction coverage
  • 86% branch coverage
  • 100% class coverage
  • Generated in target/site/jacoco/

But not uploaded to Codecov, so badge is meaningless.

Current Badges in README

Badge Status Accuracy
Build Status ✅ Working Accurate
Codecov ❌ Broken Not configured
License ✅ Working Accurate
Maven Central ⚠️ Misleading Says "packagecloud" but links to packagecloud.io (OK)
Java Version ✅ Working Accurate
Coverage (manual) ✅ Working Accurate (but manual - needs updates)
Quality ✅ Working Accurate (but manual)

Impact

1. User Confusion

  • Badge shows coverage data doesn't exist
  • Users think project has poor/no coverage
  • Reality: 93% coverage - excellent!

2. Misleading Information

  • Badge implies Codecov integration
  • Developers may expect coverage reports on Codecov
  • Reality: Coverage only in CI artifacts

3. Maintenance Burden

If Codecov not intended:

  • Broken badge in prominent location
  • Needs removal or replacement

If Codecov intended:

  • Missing integration setup
  • Badge premature

Root Cause Analysis

Likely Scenario

Issue #161 recommended adding coverage badges:

Add Codecov/Coveralls + shields.io badges

Someone added Codecov badge before setting up Codecov integration.

What's Missing

.github/workflows/main.yml needs:

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
    files: ./target/site/jacoco/jacoco.xml
    fail_ci_if_error: false

AND Codecov account setup at https://codecov.io

Recommended Solutions

Option 1: Complete Codecov Integration (Recommended if using Codecov)

1. Sign up at Codecov.io

2. Get Codecov Token

  • Codecov dashboard → Repository Settings → Copy token
  • Add to GitHub Secrets: CODECOV_TOKEN

3. Update CI Workflows

Add to main.yml and pr-validation.yml:

- name: Generate JaCoCo Coverage Report
  run: mvn jacoco:report

- name: Upload coverage to Codecov
  uses: codecov/codecov-action@v4
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
    files: ./target/site/jacoco/jacoco.xml
    flags: unittests
    name: codecov-jcommons
    fail_ci_if_error: false

4. Verify Badge Works

After first upload, badge should show actual coverage (93%).

Option 2: Replace with Manual Badge (Simpler)

If not using Codecov, replace with shields.io static badge:

<!-- Remove codecov badge -->
- [![codecov](https://codecov.io/gh/FlossWare/jcommons/branch/main/graph/badge.svg)](https://codecov.io/gh/FlossWare/jcommons)

<!-- Add manual coverage badge -->
+ ![Coverage](https://img.shields.io/badge/coverage-93%25-brightgreen)

Benefits:

  • No external service needed
  • Accurate coverage display
  • Simple to maintain

Drawbacks:

  • Must manually update when coverage changes
  • No coverage history/trends
  • No PR coverage diff comments

Option 3: Use Coveralls Instead

Alternative to Codecov:

- name: Upload coverage to Coveralls
  uses: coverallsapp/github-action@v2
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    path-to-lcov: ./target/site/jacoco/jacoco.xml

Badge:

[![Coverage Status](https://coveralls.io/repos/github/FlossWare/jcommons/badge.svg?branch=main)](https://coveralls.io/github/FlossWare/jcommons?branch=main)

Current Coverage Reporting

What Works ✅

  • JaCoCo generates reports: target/site/jacoco/
  • CI uploads coverage artifacts (pr-validation.yml)
  • Can download and view reports manually

What's Missing ❌

  • No public coverage dashboard
  • No coverage history tracking
  • No PR coverage comparison
  • Badge doesn't reflect actual data

Comparison: Manual vs Service Badges

Manual Coverage Badge

![Coverage](https://img.shields.io/badge/coverage-93%25-brightgreen)

Pros:

  • Simple, no setup
  • No external dependencies
  • Always accurate (when updated)

Cons:

  • Manual updates required
  • No historical data
  • No PR integration

Codecov/Coveralls Badge

Pros:

  • Auto-updates on every commit
  • Coverage history/trends
  • PR diff comments ("Coverage increased 2%")
  • Interactive coverage browser
  • Quality gate enforcement

Cons:

  • Requires account setup
  • External service dependency
  • Slightly more complex CI config

Recommendation

For Production Library (Like jcommons)

Use Codecov or Coveralls (Option 1 or 3):

  • Shows commitment to quality
  • Transparent coverage tracking
  • Industry standard for open-source

Time investment: ~15 minutes setup

For Personal/Small Projects

Use manual badge (Option 2):

  • Quick, simple
  • No maintenance overhead
  • Good enough for small projects

Documentation Updates

If Using Codecov

Add to README:

## Code Coverage

This project maintains high test coverage tracked via [Codecov](https://codecov.io/gh/FlossWare/jcommons):
- 93% instruction coverage
- 86% branch coverage
- 100% class coverage

Coverage reports are generated on every commit.

If Using Manual Badge

Add to CONTRIBUTING.md:

## Updating Coverage Badge

After coverage changes:
1. Run: `mvn jacoco:report`
2. Check: `target/site/jacoco/index.html`
3. Update README.md badge: `coverage-XX%25`

Verification

After Codecov Integration

  1. Check Codecov dashboard shows data
  2. Badge displays correct percentage
  3. Click badge → should show detailed coverage
  4. Open PR → should see coverage comment

After Manual Badge

  1. Badge shows correct percentage (93%)
  2. Color is green (>90% = green)
  3. Link goes somewhere useful (Actions or coverage report)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions