Skip to content

Updated Formatter for better metrics#12

Open
shetty-tejas wants to merge 1 commit intocodeclimate-community:masterfrom
shetty-tejas:master
Open

Updated Formatter for better metrics#12
shetty-tejas wants to merge 1 commit intocodeclimate-community:masterfrom
shetty-tejas:master

Conversation

@shetty-tejas
Copy link
Copy Markdown

Re-opened the previous PR: #7.


I was making a Github Actions project for working with SimpleCov. Turns out this being the recommended gem by SimpleCov, didn't have some functionalities I was thinking of adding support for. So added it here in this PR. If you have any thoughts or suggestions do let me know 😄

What's Changed:

  • Minimum Coverage Check for file. If fails, the file name and the percent_covered is collected in errors.
  • Groups now contain more information such as covered_lines, missed_lines and total_lines.
  • Also returns config details like minimum_coverage and minimum_coverage_by_file.
  • Total metrics as default (even when groups are not available).

@shetty-tejas shetty-tejas force-pushed the master branch 2 times, most recently from f9df56c to d0c8e8d Compare May 21, 2025 12:42
@shetty-tejas
Copy link
Copy Markdown
Author

@pboling @f-moya Any changes you guys would like me to integrate?

@pboling pboling mentioned this pull request Jul 1, 2025
Copy link
Copy Markdown
Contributor

@pboling pboling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pboling
Copy link
Copy Markdown
Contributor

pboling commented Jul 16, 2025

Ping @f-moya

@shetty-tejas
Copy link
Copy Markdown
Author

@f-moya It has been a long time since this PR was raised. Can you check it out please? I think this is a great improvement and should be a part of any new release that would be created.

@shetty-tejas
Copy link
Copy Markdown
Author

ping @f-moya!

@sferik
Copy link
Copy Markdown

sferik commented Apr 3, 2026

FYI, I’m planning to merge simplecov_json_formatter into the main SimpleCov codebase, as I just did with simplecov-html.

@sferik
Copy link
Copy Markdown

sferik commented Apr 4, 2026

@shetty-tejas I’ve merged this repo into the SimpleCov repo: simplecov-ruby/simplecov@253c19e. This repo should be archived soon. Feel free to open a version of the PR in that repo. I promise it will be reviewed quickly.

sferik added a commit to simplecov-ruby/simplecov that referenced this pull request 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.

Co-Authored-By: Tejas <tejas.shetty@mailbox.org>
@sferik
Copy link
Copy Markdown

sferik commented Apr 4, 2026

@shetty-tejas Thanks for this PR! Since I’ve merged simplecov_json_formatter directly into SimpleCov, I've implemented a version of these enhancements in the main repo instead.

Here’s what I kept from your proposal:

  • Per-file coverage percentages
  • Richer group metrics (covered, missed, total counts + percent)
  • A top-level total section with aggregate stats

Here’s what I changed:

  • No errors key – minimum coverage checking is already handled by SimpleCov’s exit codes, so duplicating it in the JSON would couple the formatter to configuration
  • No config in meta – likewise, the formatter shouldn’t expose SimpleCov’s internal configuration
  • All three coverage types – line, branch, and method coverage are all supported consistently throughout (total, groups, and per-file), not just line coverage
  • Method coverage data – per-file output includes a methods array (similar to the existing branches array) when method coverage is enabled
  • SimpleCov.root instead of Dir.pwd for path operations – this is more stable
  • Full stats shape – total and group stats include covered, missed, total, percent, and strength (using CoverageStatistics directly), rather than ad-hoc fields

I believe this PR can be closed, since the external gem repo is no longer the right target for changes, but wanted to make sure you got credit for the contribution. Feel free to give me feedback at simplecov-ruby/simplecov#1164. Thanks again!

sferik added a commit to simplecov-ruby/simplecov that referenced this pull request 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.

Co-Authored-By: Tejas <tejas.shetty@mailbox.org>
sferik added a commit to simplecov-ruby/simplecov that referenced this pull request 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.

Co-Authored-By: Tejas <tejas.shetty@mailbox.org>
sferik added a commit to simplecov-ruby/simplecov that referenced this pull request 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.

Co-Authored-By: Tejas <tejas.shetty@mailbox.org>
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