Repository navigation
fix(ci): stop a narrow subprocess-ratchet scan from wiping the baseline - #3751
Conversation
Found while checking PR #3749's new test against the ratchet. Running subprocess_capture_checker.py ci/tests/some_file.py reported "239 baselined subprocess usage(s) are now gone" -- because the improvement check compared the whole baseline against a single file's findings. Every entry for a file that was simply not examined counted as fixed. That message is wrong on its own, but the dangerous part is the action it invites: adding --update-baseline to that same narrow command rewrote the baseline from just that file, silently deleting the other 128 entries and turning the ratchet off across the repo. The next raw Popen would have gone in unnoticed. Both halves now key off the set of files actually scanned: - --update-baseline merges instead of overwriting, keeping entries for unscanned files verbatim. A file that genuinely improved still shrinks or drops out, so the ratchet can still be tightened incrementally. - The "now gone" note only counts entries for files this run looked at. Also drops the two check_array_params/check_noexcept SRC004 entries that #3747 resolved -- the baseline was generated just before that merged, so it was stale by exactly those two. Tests cover the narrow-update case, the misleading note, that a rescanned file can still shrink, and that a genuinely new violation still fails. The first three fail against the previous implementation. Validated: 556 passed / 39 skipped in ci/tests, lint green. Co-Authored-By: Claude <[email protected]>
📝 WalkthroughWalkthroughThe subprocess checker now tracks scanned files, preserves baseline entries for unscanned files during updates, limits “now gone” reporting to scanned files, and adds regression tests. Two obsolete ChangesSubprocess baseline ratcheting
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/tests/test_subprocess_checker_baseline.py`:
- Around line 51-53: Annotate the capsys parameter in
test_narrow_scan_does_not_claim_unscanned_entries_improved with the appropriate
pytest capture fixture type, preserving the existing tmp_path annotation and
test behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 21c32961-877e-47b6-a6e2-2ec1a4a7cb9d
📒 Files selected for processing (3)
ci/lint_python/subprocess_baseline.txtci/lint_python/subprocess_capture_checker.pyci/tests/test_subprocess_checker_baseline.py
💤 Files with no reviewable changes (1)
- ci/lint_python/subprocess_baseline.txt
|
Fixed in 3416ce9 — annotated
|
Follow-up to #3748. Found while checking #3749's new test file against the ratchet.
The bug
Running the checker against a single file:
reported "239 baselined subprocess usage(s) are now gone" — because the improvement check compared the entire baseline against one file's findings. Every entry for a file that was simply never examined counted as fixed.
The wrong message is bad. The action it invites is worse: adding
--update-baselineto that same narrow command rewrote the baseline from just that file, silently deleting the other 128 entries and turning the ratchet off across the repo. The next rawPopenwould have gone in unnoticed — the failure mode being that a guard reports success while no longer guarding anything.Fix
Both halves now key off the set of files actually scanned:
--update-baselinemerges instead of overwriting, keeping entries for unscanned files verbatim. A file that genuinely improved still shrinks or drops out, so incremental tightening still works — it just can't delete what it didn't look at.Baseline cleanup
Also drops the two
check_array_params/check_noexceptSRC004entries that #3747 resolved. The baseline in #3748 was generated just before #3747 merged, so it was stale by exactly those two. Full scan is now exact — no residual note.Tests
ci/tests/test_subprocess_checker_baseline.pycovers:--update-baselinepreserves unscanned entriesThe first three fail against the previous implementation; the fourth passes both, which is the correct split — it's the property that must not regress while fixing the others.
Validation
556 passed, 39 skippedinci/tests;bash lintgreen.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests