Skip to content

Add richer metrics to JSON formatter#1164

Open
sferik wants to merge 2 commits intomainfrom
json-formatter-metrics
Open

Add richer metrics to JSON formatter#1164
sferik wants to merge 2 commits intomainfrom
json-formatter-metrics

Conversation

@sferik
Copy link
Copy Markdown
Collaborator

@sferik sferik commented Apr 4, 2026

Enhance the JSON coverage output with per-file coverage percentages, a total section with aggregate statistics, full group stats, and method coverage support.

Per-file output now includes covered_percent (always), and when enabled: branches_covered_percent and methods array with methods_covered_percent. The total and groups sections report full statistics (covered, missed, total, percent, strength) for each enabled coverage type (line, branch, method).

Breaking change: group stats change from { covered_percent: 80.0 } to the full stats shape with the key renamed to percent.

Based on the ideas in codeclimate-community/simplecov_json_formatter#12.

This comment was marked as resolved.

@sferik sferik force-pushed the json-formatter-metrics branch from 35f35b5 to 30e31e9 Compare April 4, 2026 17:37
Enhance the JSON coverage output with per-file coverage percentages, a
total section with aggregate statistics, full group stats, and method
coverage support.

Per-file output now includes covered_percent (always), and when enabled:
branches_covered_percent and methods array with methods_covered_percent.
The total and groups sections report full statistics (covered, missed,
total, percent, strength) for each enabled coverage type (line, branch,
method).

Breaking change: group stats change from { covered_percent: 80.0 } to
the full stats shape with the key renamed to percent.

Based on the ideas in codeclimate-community/simplecov_json_formatter#12.

Co-Authored-By: Tejas <tejas.shetty@mailbox.org>
@sferik sferik force-pushed the json-formatter-metrics branch from 30e31e9 to 8931869 Compare April 4, 2026 17:47
@sferik sferik force-pushed the json-formatter-metrics branch from d8be1a3 to 94db9fa Compare April 7, 2026 02:30
Report all four types of coverage threshold violations in the JSON
formatter's errors object: minimum_coverage, minimum_coverage_by_file,
minimum_coverage_by_group, and maximum_coverage_drop. Each violation
includes expected and actual values. This makes the JSON self-contained
for downstream consumers (e.g. CI reporters) that don't have access to
the Ruby process.

Co-Authored-By: Tejas <tejas.shetty@mailbox.org>
@sferik sferik force-pushed the json-formatter-metrics branch from 94db9fa to 3ea2cf7 Compare April 7, 2026 02:35
@brynary
Copy link
Copy Markdown
Contributor

brynary commented Apr 14, 2026

@sferik I did a very quick review of this and one thing caught my eye... It appears as though the statistics summaries are constructed such that, definitionally, total = covered + missed.

In our data, we track a third state which is "omit", which is for blank lines and comments -- lines that cannot be covered. We then define coverage as covered / (covered + missed) (excluding blanks and comments

This is a major difference and I'm guessing this definition is not new to SimpleCov in this PR, so this is just an FYI of something that I thought I'd mention as you are on a 1.0 push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants