Merged
Conversation
… call args, and for loops
ExampleFinder was traversing too deeply into three node types that
RuboCop's shallow pattern matching does not reach:
1. LocalVariableWriteNode — skip lvasgn nodes (e.g., `examples = [...].each { it ... }`)
2. Method call arguments — only visit block children in fallthrough, not
receiver/arguments (e.g., `example` used as arg in `let` block)
3. ForNode — skip `for...in` loops (RuboCop only matches `block` nodes)
Corpus: 0 FP, 0 FN (5 resolved).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a3ac963 to
49d2d00
Compare
Contributor
|
✅ Cop-check results (8 shards)
All shards passed — ready to merge. |
6
approved these changes
Mar 30, 2026
Owner
6
left a comment
There was a problem hiding this comment.
Reviewed: logic matches vendored RuboCop behavior closely enough, and the added fixtures/tests cover the intended cases.
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.
Automated fix fix for
RSpec/EmptyExampleGroupcorpus conformance.Details
RSpec/EmptyExampleGroupResult
Changes
Agent conversation excerpt
Let me start by reading the required files to understand the problem.
Now let me check the utility functions and the RuboCop test file.
Let me check the RSPEC_EXAMPLES constant to understand what methods are recognized as examples.
Let me also look at the RSPEC_EXAMPLE_GROUPS constant to understand what's recognized as an example group.
Let me check the fixture directory structure.
Good. Now let me investigate FN #2 further before writing any code.
Let me look at the full pincers file to understand FN #2.
Now I have a clear picture of all 5 FNs. Let me read existing fixture files to understand the format.
Good. Now I understand the format. Let me create the test fixtures and then modify the code. I'll work through this step by step.
Step 1: Create test fixtures for each FN pattern.
Step 2: Verify tests fail before the fix.
I need to register the new fixtures in the test macro first.
All 5 new tests fail as expected. Now let me implement the fix.
Step 3: Fix the ExampleFinder in the Rust implementation.
Now apply the three fixes to ExampleFinder:
Now add the
visit_local_variable_write_nodeandvisit_for_nodeoverrides:Step 4: Run tests to verify the fix.
All 14 tests pass. Step 5: Validate against the corpus.
Task prompt (4936 tokens)
Fix RSpec/EmptyExampleGroup — 0 FP, 5 FN
Instructions
You are fixing ONE cop in nitrocop, a Rust Ruby linter that uses Prism for parsing.
Current state: 4,435 matches, 0 false positives, 5 false negatives.
Focus on: FN (RuboCop flags code nitrocop misses).
⚠ 4,435 existing matches must not regress. Validate with
check_cop.pybefore committing.Workflow
behavior on BOTH the specific FP case AND the general pattern:
tests/fixtures/cops/rspec/empty_example_group/offense.rbwith^annotationtests/fixtures/cops/rspec/empty_example_group/no_offense.rbcargo test --lib -- cop::rspec::empty_example_groupsrc/cop/rspec/empty_example_group.rscargo test --lib -- cop::rspec::empty_example_group///doc comment on the cop struct documenting what you found and fixedFixture Format
Mark offenses with
^markers on the line AFTER the offending source line.The
^characters must align with the offending columns. The message format isRSpec/EmptyExampleGroup: <message text>.See the Current Fixture sections below for real examples from this cop.
If your test passes immediately
If you add a test case and it passes without code changes, the corpus mismatch is
caused by config/context differences, not a detection bug.
Do NOT loop trying to make the test fail. Instead:
src/config/or the cop's config handling, not detection logica
///comment on the cop struct and commitCRITICAL: Avoid regressions in the opposite direction
When fixing FPs, your change MUST NOT suppress legitimate detections. When fixing FNs,
your change MUST NOT flag code that RuboCop accepts. A fix that eliminates a few issues
in one direction but introduces hundreds in the other is a catastrophic regression.
Before exempting a category of patterns, verify with RuboCop that the general case
is still an offense:
If RuboCop flags the general pattern but not your specific case, the difference is in
a narrow context (e.g., enclosing structure, receiver type, argument count) — your fix
must target that specific context, not the broad category.
Rule of thumb: if your fix adds an early
returnorcontinuethat skips a wholenode type, operator class, or naming pattern, it's probably too broad. Prefer adding a
condition that matches the SPECIFIC differentiating context.
Rules
src/cop/rspec/empty_example_group.rsandtests/fixtures/cops/rspec/empty_example_group/cargo test --lib -- cop::rspec::empty_example_groupto verify your fix (do NOT run the full test suite)python3 scripts/check_cop.py RSpec/EmptyExampleGroup --rerun --clone --sample 15before committing to catch regressionsgit stashCurrent Fixture: offense.rb
tests/fixtures/cops/rspec/empty_example_group/offense.rbCurrent Fixture: no_offense.rb
tests/fixtures/cops/rspec/empty_example_group/no_offense.rbKey Source Files
src/cop/rspec/empty_example_group.rsvendor/rubocop-rspec/lib/rubocop/cop/rspec/empty_example_group.rbvendor/rubocop-rspec/spec/rubocop/cop/rspec/empty_example_group_spec.rbRead these files before making changes.
Start Here
Use the existing corpus data to focus on the most concentrated regressions first.
Helpful local commands:
python3 scripts/investigate_cop.py RSpec/EmptyExampleGroup --repos-onlypython3 scripts/investigate_cop.py RSpec/EmptyExampleGroup --contextpython3 scripts/verify_cop_locations.py RSpec/EmptyExampleGroupTop FN repos:
rspec__rspec__1559574(2 FN) — examplerspec-core/spec/rspec/core/metadata_filter_spec.rb:180SciRuby__rubex__bf5ee93(1 FN) — examplespec/examples_spec.rb:3platanus__pincers__f652bff(1 FN) — examplespec/lib/nokogiri/backend_spec.rb:3Representative FN examples:
SciRuby__rubex__bf5ee93: spec/examples_spec.rb:3— Empty example group detected.platanus__pincers__f652bff: spec/lib/nokogiri/backend_spec.rb:3— Empty example group detected.rspec__rspec__1559574: rspec-core/spec/rspec/core/metadata_filter_spec.rb:180— Empty example group detected.Pre-diagnostic Results
Diagnosis Summary
Each example was tested by running nitrocop on the extracted source in isolation
with
--force-default-configto determine if the issue is a code bug or config issue.Note: source context is truncated and may not parse perfectly. If a diagnosis
seems wrong (e.g., your test passes immediately for a 'CODE BUG'), treat it as
a config/context issue instead.
FN #1:
SciRuby__rubex__bf5ee93: spec/examples_spec.rb:3NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Message:
Empty example group detected.Ready-made test snippet (add to offense.rb, adjust
^count):Full file context (30 lines before offense):
FN #2:
platanus__pincers__f652bff: spec/lib/nokogiri/backend_spec.rb:3NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Message:
Empty example group detected.Ready-made test snippet (add to offense.rb, adjust
^count):Full file context (30 lines before offense):
FN #3:
rspec__rspec__1559574: rspec-core/spec/rspec/core/metadata_filter_spec.rb:180NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Full-file enclosing chain: block (do..end) (line 178:
let(:metadata_with_array) do) > block (do..end) (line 177:context "with an Array" do) > block (do..end) (line 4:describe ".filter_applies?" do) > block (do..end) (line 3:RSpec.describe MetadataFilter do) > module body (line 2:module Core) > module body (line 1:module RSpec)Message:
Empty example group detected.Ready-made test snippet (add to offense.rb, adjust
^count):Full file context (30 lines before offense):
FN #4:
rspec__rspec__1559574: rspec-core/spec/rspec/core/notifications_spec.rb:122NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Full-file enclosing chain: block (do..end) (line 120:
let(:exception) do) > block (do..end) (line 119:context "due to using:aggregate_failuresmetadata" do) > block (do..end) (line 42:context "when the exception is a MultipleExpectationsNotMetError" do) > block (do..end) (line 33:describe "fully formatted failure output" do) > block (do..end) (line 10:RSpec.describe "FailedExampleNotification" do)Message:
Empty example group detected.Ready-made test snippet (add to offense.rb, adjust
^count):Full file context (30 lines before offense):
FN #5:
saulabs__reportable__5aacafa: spec/classes/grouping_spec.rb:39NOT DETECTED — CODE BUG
The cop fails to detect this pattern. Fix the detection logic.
Full-file enclosing chain: block (do..end) (line 13:
describe '#to_sql' do) > block (do..end) (line 3:describe Saulabs::Reportable::Grouping do)Message:
Empty example group detected.Ready-made test snippet (add to offense.rb, adjust
^count):Full file context (30 lines before offense):