Add --fail-on-low-coverage flag to exit non-zero on under-covered files - #12
Merged
Conversation
Add a boolean --fail-on-low-coverage CLI flag. When set, couve writes the report and then exits 1 if any reported file is below the green threshold (rated red or yellow, < 66.66%), printing the offending files to stderr. Extract the 33.33 / 66.66 magic numbers into RED_THRESHOLD / GREEN_THRESHOLD constants and add public Parser#low_coverage? / #low_coverage_files, which respect the existing --changed-files scope. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11
Summary
--fail-on-low-coverageCLI flag. When set, couve writes the report and then exits1if any reported file is below the green threshold (rated 🔴 or 🟡,< 66.66%).couve: coverage below 66.66% in app/foo.rb, app/bar.rb.33.33/66.66magic numbers intoRED_THRESHOLD/GREEN_THRESHOLDconstants (shared bypercentage_bar_colorandpercentage_indicator).Couve::Parser#low_coverage?and#low_coverage_files. Since the constructor already narrows the source files to the reported set, these automatically respect--changed-filesscope — a green or empty changed-file set passes the build.How to test
bundle exec rspec— 35 examples, 0 failures.bin/rubocop— no offenses.couve spec/fixtures/codeclimate.json report.md --fail-on-low-coverageexits1(the fixture'speople_resolver.rbis at 60%) and prints the offending file to stderr, while still writingreport.md.0:echo app/javascript/routes.jsx | couve spec/fixtures/codeclimate.json report.md --changed-files - --fail-on-low-coverage.Notes
.semaphore/semaphore.ymlCoverage block so it posts the comment first, then fails.🤖 Generated with Claude Code