[GH-8922] Add support for only one error per file in Rubyzen - #35
Open
Eric Silverberg (esilverberg) wants to merge 1 commit into
Open
[GH-8922] Add support for only one error per file in Rubyzen#35Eric Silverberg (esilverberg) wants to merge 1 commit into
Eric Silverberg (esilverberg) wants to merge 1 commit into
Conversation
Copilot started reviewing on behalf of
Eric Silverberg (esilverberg)
September 13, 2026 18:39
View session
There was a problem hiding this comment.
Pull request overview
Adds one_per_file support to reduce displayed violations while preserving full evaluation.
Changes:
- Adds shared per-file filtering.
- Exposes the option across RSpec matchers and Minitest assertions.
- Documents the option and adds initial regression coverage.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Summary |
|---|---|
spec/matchers/zen_empty_matcher_spec.rb |
Adds per-file output regression coverage. |
README.md |
Documents one_per_file. |
lib/rubyzen/matchers/zen_true_matcher.rb |
Adds option support to the true matcher. |
lib/rubyzen/matchers/zen_false_matcher.rb |
Adds option support to the false matcher. |
lib/rubyzen/matchers/zen_empty_matcher.rb |
Adds option support to the empty matcher. |
lib/rubyzen/expectation_helpers.rb |
Implements shared classification and per-file filtering. |
lib/rubyzen/assertions/assert_zen_true.rb |
Adds option support to the true assertion. |
lib/rubyzen/assertions/assert_zen_false.rb |
Adds option support to the false assertion. |
lib/rubyzen/assertions/assert_zen_empty.rb |
Adds option support to the empty assertion. |
Suppressed comments (1)
lib/rubyzen/expectation_helpers.rb:102
one_per_fileis now threaded through all six public entry points, but the only added example coverszen_emptyin RSpec. Add equivalent coverage for thezen_true/zen_falsematcher paths and all three Minitest assertions (ideally with multiple files) so regressions in those new branches cannot leave the suite green.
raw_violations = Array(grouped_items[:violations])
violations_to_display = one_per_file ? filter_one_per_file(raw_violations) : raw_violations
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
70
to
+71
| # @return [Hash{Symbol => Array<String>}] keys: :violations, :baseline, :allowlist, | ||
| # :stale_baseline, :stale_allowlist | ||
| def classify_items(subject_collection, allowlist: nil, baseline: nil) | ||
| # :stale_baseline, :stale_allowlist, :violations_raw |
| Rubyzen::Collections::ClassesCollection.new(file.classes) | ||
| end | ||
|
|
||
| it 'displays only the first violation from each file' do |
| expect(non_empty_collection).not_to zen_empty | ||
| end | ||
|
|
||
| describe 'with one_per_file' do |
Collaborator
There was a problem hiding this comment.
Should we add one test in the Minitest assertions as well?
| # end | ||
| # end | ||
| RSpec::Matchers.define :zen_true do |custom_message=nil, allowlist: nil, baseline: nil| | ||
| RSpec::Matchers.define :zen_true do |custom_message=nil, allowlist: nil, baseline: nil, one_per_file: false| |
Collaborator
There was a problem hiding this comment.
If we print maximum one violation per file, it would be nice to at least show how many we have in total, something like:
Violations
- element: foo
- file: a.rb:3 (+2 more in this file)
This can be done in a follow-up PR as well
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.
What changed and why
Checklist
bundle exec rakepasses locally (runs both the RSpec and Minitest suites)[GH-8922] Add support for only one error per file in Rubyzen
We want to support only printing one error per file, so we can more easily create baselines