fix: deduplicate glob results in snap_diff:clean#178
Conversation
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>
|
Warning Rate limit exceeded
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 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideDeduplicates 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 removalsequenceDiagram
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
Flow diagram for snap_diff_clean rake task with deduplicationflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary
.uniqto glob results insnap_diff:cleanrake task to prevent over-counting when overlapping patterns (*.diff.pngmatches*.base.diff.pngand*.heatmap.diff.png) produce duplicate pathsContext
Found via CodeRabbit review on #177
Test plan
rake snap_diff:cleanreports accurate count🤖 Generated with Claude Code
Summary by Sourcery
Bug Fixes: