Skip to content

fix: deduplicate glob results in snap_diff:clean#178

Merged
pftg merged 1 commit intomasterfrom
fix/rakefile-dedup-and-review-triage
Apr 12, 2026
Merged

fix: deduplicate glob results in snap_diff:clean#178
pftg merged 1 commit intomasterfrom
fix/rakefile-dedup-and-review-triage

Conversation

@pftg
Copy link
Copy Markdown
Collaborator

@pftg pftg commented Apr 12, 2026

Summary

  • Add .uniq to glob results in snap_diff:clean rake task to prevent over-counting when overlapping patterns (*.diff.png matches *.base.diff.png and *.heatmap.diff.png) produce duplicate paths

Context

Found via CodeRabbit review on #177

Test plan

  • rake snap_diff:clean reports accurate count
  • Unit tests pass

🤖 Generated with Claude Code

Summary by Sourcery

Bug Fixes:

  • Ensure snap_diff:clean reports an accurate count of removed diff artifacts when glob patterns overlap.

Overlapping globs (*.diff.png matches *.base.diff.png and *.heatmap.diff.png)
produced duplicate paths, causing the "Removed N" count to over-report.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

Warning

Rate limit exceeded

@pftg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 26 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 16 minutes and 26 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 74b1bca6-53f9-4c57-ade6-e8983cecef4f

📥 Commits

Reviewing files that changed from the base of the PR and between e032565 and 7ec0b09.

📒 Files selected for processing (1)
  • Rakefile
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rakefile-dedup-and-review-triage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Deduplicates the list of files found by glob patterns in the snap_diff:clean rake task so that overlapping patterns don’t cause files to be removed or counted multiple times.

Sequence diagram for snap_diff_clean rake task file removal

sequenceDiagram
    participant RakeTask as snap_diff_clean
    participant Dir as Dir
    participant FileUtils as FileUtils

    RakeTask->>RakeTask: Define patterns array
    loop For each pattern
        RakeTask->>Dir: glob tmp/pattern
        Dir-->>RakeTask: tmp_matches
        RakeTask->>Dir: glob doc/screenshots/pattern
        Dir-->>RakeTask: doc_matches
        RakeTask->>RakeTask: Append tmp_matches and doc_matches to removed
    end
    RakeTask->>RakeTask: removed = removed.uniq
    loop For each file in removed
        RakeTask->>FileUtils: rm_f file
    end
    RakeTask->>RakeTask: Print Removed removed.size diff artifacts
Loading

Flow diagram for snap_diff_clean rake task with deduplication

flowchart TD
    A[Start snap_diff_clean task] --> B[Define patterns array]
    B --> C[Initialize removed list]
    C --> D{More patterns?}
    D -->|Yes| E[Select next pattern]
    E --> F[Dir.glob tmp/pattern]
    F --> G[Dir.glob doc/screenshots/pattern]
    G --> H[Append all matches to removed]
    H --> D
    D -->|No| I[Apply removed.uniq]
    I --> J{Files in removed?}
    J -->|Yes| K[FileUtils.rm_f for each file]
    K --> L[Increment removed count]
    L --> J
    J -->|No| M[Print Removed removed.size diff artifacts]
    M --> N[End task]
Loading

File-Level Changes

Change Details Files
Ensure snap_diff:clean deduplicates globbed file paths before deletion and reporting counts.
  • Collect globbed paths from tmp and doc/screenshots for all diff-related patterns, then apply uniq to the combined list
  • Preserve existing behavior of deleting each path with FileUtils.rm_f and reporting the total removed count, but now using the deduplicated list
Rakefile

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@pftg pftg merged commit 2e5103d into master Apr 12, 2026
2 checks passed
@pftg pftg deleted the fix/rakefile-dedup-and-review-triage branch April 12, 2026 20:53
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.

1 participant